activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r397654 [3/12] - in /incubator/activemq/trunk/openwire-cpp: ./ src/ src/command/ src/gram/ src/gram/java/ src/gram/java/org/ src/gram/java/org/apache/ src/gram/java/org/apache/activemq/ src/gram/java/org/apache/activemq/openwire/ src/gram/j...
Date Thu, 27 Apr 2006 21:59:44 GMT
Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/Session.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/Session.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/Session.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/Session.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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.
+ */
+#ifndef ActiveMQ_Session_hpp_
+#define ActiveMQ_Session_hpp_
+
+#include <string>
+#include <map>
+#include "activemq/AcknowledgementMode.hpp"
+#include "cms/IMessage.hpp"
+#include "cms/IBytesMessage.hpp"
+#include "cms/IMapMessage.hpp"
+#include "cms/ITextMessage.hpp"
+#include "cms/ISession.hpp"
+#include "cms/CmsException.hpp"
+#include "activemq/IDataStructure.hpp"
+#include "activemq/MessageConsumer.hpp"
+#include "activemq/MessageProducer.hpp"
+#include "activemq/TransactionContext.hpp"
+#include "activemq/command/ConsumerInfo.hpp"
+#include "activemq/command/ProducerInfo.hpp"
+#include "activemq/command/RemoveInfo.hpp"
+#include "activemq/command/SessionInfo.hpp"
+#include "activemq/command/SessionId.hpp"
+#include "ppr/thread/SimpleMutex.hpp"
+#include "ppr/thread/Semaphore.hpp"
+#include "ppr/thread/Thread.hpp"
+#include "ppr/util/ifr/array"
+#include "ppr/util/ifr/p"
+
+namespace apache
+{
+  namespace activemq
+  {
+      using namespace ifr;
+      using namespace apache::cms;
+      using namespace apache::ppr::thread;
+      using namespace apache::ppr::util;
+      class Connection;
+      class DispatchThread;
+
+/*
+ * 
+ */
+class Session : public ISession
+{
+private:
+    p<Connection>                 connection ;
+    p<SessionInfo>                sessionInfo ;
+    AcknowledgementMode           ackMode ;
+    p<TransactionContext>         transactionContext ;
+    p<DispatchThread>             dispatchThread ;
+    map<long long, p<MessageConsumer> > consumers ;
+    map<long long, p<MessageProducer> > producers ;
+    SimpleMutex                   mutex ;
+    long                          consumerCounter,
+                                  producerCounter ;
+    int                           prefetchSize ;
+    bool                          closed ;
+
+public:
+    Session(p<Connection> connection, p<SessionInfo> sessionInfo, AcknowledgementMode ackMode) ;
+    virtual ~Session() ;
+
+    // Attribute methods
+    virtual bool isTransacted() ;
+    virtual p<Connection> getConnection() ;
+    virtual p<SessionId> getSessionId() ;
+    virtual p<TransactionContext> getTransactionContext() ;
+    virtual p<MessageConsumer> getConsumer(p<ConsumerId> consumerId) ;
+    virtual p<MessageProducer> getProducer(p<ProducerId> producerId) ;
+
+    // Operation methods
+    virtual void commit() throw(CmsException) ;
+    virtual void rollback() throw(CmsException) ;
+    virtual p<IMessageProducer> createProducer() ;
+    virtual p<IMessageProducer> createProducer(p<IDestination> destination) ;
+    virtual p<IMessageConsumer> createConsumer(p<IDestination> destination) ;
+    virtual p<IMessageConsumer> createConsumer(p<IDestination> destination, const char* selector) ;
+    virtual p<IMessageConsumer> createDurableConsumer(p<ITopic> destination, const char* name, const char* selector, bool noLocal) ;
+    virtual p<IQueue> getQueue(const char* name) ;
+    virtual p<ITopic> getTopic(const char* name) ;
+    virtual p<ITemporaryQueue> createTemporaryQueue() ;
+    virtual p<ITemporaryTopic> createTemporaryTopic() ;
+    virtual p<IMessage> createMessage() ;
+    virtual p<IBytesMessage> createBytesMessage() ;
+    virtual p<IBytesMessage> createBytesMessage(char* body, int size) ;
+    virtual p<IMapMessage> createMapMessage() ;
+    virtual p<ITextMessage> createTextMessage() ;
+    virtual p<ITextMessage> createTextMessage(const char* text) ;
+
+    virtual void doSend(p<IDestination> destination, p<IMessage> message) ;
+    virtual void doStartTransaction() ;
+    virtual void dispatch(int delay = 0) ;
+    virtual void dispatchAsyncMessages() ;
+    virtual void close() ;
+
+protected:
+    // Implementation methods
+    p<ConsumerInfo> createConsumerInfo(p<IDestination> destination, const char* selector) ;
+    p<ProducerInfo> createProducerInfo(p<IDestination> destination) ;
+    void configure(p<IMessage> message) ;
+} ;
+
+/*
+ * 
+ */
+class DispatchThread : public Thread
+{
+public:
+    p<Session> session ;
+    Semaphore  semaphore ;
+    bool       interrupted ;
+
+    DispatchThread(p<Session> session)
+    {
+        this->session = session ;
+        this->interrupted = false ;
+    }
+
+    void interrupt()
+    {
+        interrupted = true ;
+    }
+
+    void wakeup()
+    {
+        semaphore.notify() ;
+    }
+
+protected:
+    virtual void run () throw (p<exception>) 
+    {
+        while( !interrupted )
+        {
+            // Wait for wake-up call
+            semaphore.wait() ;
+
+            session->dispatchAsyncMessages() ;
+        }
+    }
+} ;
+
+/* namespace */
+  }
+}
+
+#endif /*ActiveMQ_Session_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/TransactionContext.cpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/TransactionContext.cpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/TransactionContext.cpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/TransactionContext.cpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 "activemq/TransactionContext.hpp"
+#include "activemq/Session.hpp"
+
+using namespace apache::activemq;
+
+/*
+ * 
+ */
+TransactionContext::TransactionContext(p<Session> session)
+{
+    this->session       = session ;
+    this->transactionId = NULL ;
+}
+
+/*
+ * 
+ */
+TransactionContext::~TransactionContext()
+{
+    // no-op
+}
+
+/*
+ * 
+ */
+p<TransactionId> TransactionContext::getTransactionId()
+{
+    return transactionId ;
+}
+
+/*
+ * 
+ */
+void TransactionContext::addSynchronization(p<ISynchronization> synchronization)
+{
+    synchronizations.push_back(synchronization) ;
+}
+
+/*
+ * 
+ */
+void TransactionContext::begin()
+{
+    if( transactionId == NULL )
+    {
+        // Create a new local transaction id
+        transactionId = session->getConnection()->createLocalTransactionId() ;
+
+        // Create a new transaction command
+        p<TransactionInfo> info = new TransactionInfo() ;
+        info->setConnectionId( session->getConnection()->getConnectionId() ) ;
+        info->setTransactionId( transactionId ) ;
+        info->setType( BeginTx ) ;
+
+        // Send begin command to broker
+        session->getConnection()->oneway(info) ;
+    }
+}
+
+/*
+ * 
+ */
+void TransactionContext::commit()
+{
+    list< p<ISynchronization> >::const_iterator tempIter ;
+
+    // Iterate through each synchronization and call beforeCommit()
+    for( tempIter = synchronizations.begin() ;
+         tempIter != synchronizations.end() ;
+         tempIter++ )
+    {
+        (*tempIter)->beforeCommit() ;
+    }
+
+    if( transactionId != NULL )
+    {
+        // Create a new transaction command
+        p<TransactionInfo> info = new TransactionInfo() ;
+        info->setConnectionId( session->getConnection()->getConnectionId() ) ;
+        info->setTransactionId( transactionId ) ;
+        info->setType( CommitOnePhaseTx ) ;
+
+        // Reset transaction
+        transactionId = NULL ;
+
+        // Send commit command to broker
+        session->getConnection()->oneway(info) ;
+    }
+
+    // Iterate through each synchronization and call afterCommit()
+    for( tempIter = synchronizations.begin() ;
+         tempIter != synchronizations.end() ;
+         tempIter++ )
+    {
+        (*tempIter)->afterCommit() ;
+    }
+
+    // Clear all syncronizations
+    synchronizations.clear() ;
+}
+
+/*
+ * 
+ */
+void TransactionContext::rollback()
+{
+    if( transactionId != NULL )
+    {
+        // Create a new transaction command
+        p<TransactionInfo> info = new TransactionInfo() ;
+        info->setConnectionId( session->getConnection()->getConnectionId() ) ;
+        info->setTransactionId( transactionId ) ;
+        info->setType( RollbackTx ) ;
+
+        // Reset transaction
+        transactionId = NULL ;
+
+        // Send rollback command to broker
+        session->getConnection()->oneway(info) ;
+    }
+
+    list< p<ISynchronization> >::const_iterator tempIter ;
+
+    // Iterate through each synchronization and call afterRollback()
+    for( tempIter = synchronizations.begin() ;
+         tempIter != synchronizations.end() ;
+         tempIter++ )
+    {
+        (*tempIter)->afterRollback() ;
+    }
+    // Clear all syncronizations
+    synchronizations.clear() ;
+}

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/TransactionContext.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/TransactionContext.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/TransactionContext.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/TransactionContext.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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.
+ */
+#ifndef ActiveMQ_TransactionContext_hpp_
+#define ActiveMQ_TransactionContext_hpp_
+
+#include <list>
+#include "activemq/ISynchronization.hpp"
+#include "activemq/Connection.hpp"
+#include "activemq/TransactionType.hpp"
+#include "activemq/command/TransactionId.hpp"
+#include "activemq/command/TransactionInfo.hpp"
+#include "ppr/util/ifr/p"
+
+namespace apache
+{
+  namespace activemq
+  {
+    using namespace ifr;
+    using namespace apache::activemq::command;
+    class Session;
+
+/*
+ * 
+ */
+class TransactionContext
+{
+private:
+     p<TransactionId>            transactionId ;
+     p<Session>                  session ;
+     list< p<ISynchronization> > synchronizations ;
+
+public:
+    TransactionContext(p<Session> session) ;
+    virtual ~TransactionContext() ;
+
+    virtual p<TransactionId> getTransactionId() ;
+    virtual void addSynchronization(p<ISynchronization> synchronization) ;
+    virtual void begin() ;
+    virtual void commit() ;
+    virtual void rollback() ;
+} ;
+
+/* namespace */
+  }
+}
+
+#endif /*ActiveMQ_TransactionContext_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/TransactionType.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/TransactionType.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/TransactionType.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/TransactionType.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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.
+ */
+#ifndef ActiveMQ_TransactionType_hpp_
+#define ActiveMQ_TransactionType_hpp_
+
+namespace apache
+{
+  namespace activemq
+  {
+    enum TransactionType
+    {
+      BeginTx = 0,
+      PrepareTx = 1,
+      CommitOnePhaseTx = 2,
+      CommitTwoPhaseTx = 3,
+      RollbackTx = 4,
+      RecoverTx = 5,
+      ForgetTx = 6,
+      EndTx = 7
+    };
+  }
+}
+
+#endif /*ActiveMQ_TransactionType_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.cpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.cpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.cpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.cpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,270 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 <string.h>
+#include "activemq/command/AbstractCommand.hpp"
+#include "activemq/command/ActiveMQMessage.hpp"
+#include "activemq/command/ActiveMQBytesMessage.hpp"
+#include "activemq/command/ActiveMQMapMessage.hpp"
+#include "activemq/command/ActiveMQObjectMessage.hpp"
+#include "activemq/command/ActiveMQStreamMessage.hpp"
+#include "activemq/command/ActiveMQTextMessage.hpp"
+#include "activemq/command/ActiveMQQueue.hpp"
+#include "activemq/command/ConsumerId.hpp"
+#include "activemq/command/ProducerId.hpp"
+#include "activemq/command/MessageId.hpp"
+#include "activemq/command/LocalTransactionId.hpp"
+#include "activemq/command/MessageAck.hpp"
+#include "activemq/command/MessageDispatch.hpp"
+#include "activemq/command/Response.hpp"
+#include "activemq/command/ConsumerInfo.hpp"
+#include "activemq/command/IntegerResponse.hpp"
+#include "activemq/command/ProducerInfo.hpp"
+#include "activemq/command/BrokerInfo.hpp"
+#include "activemq/command/KeepAliveInfo.hpp"
+#include "activemq/command/ConnectionInfo.hpp"
+#include "activemq/command/RemoveInfo.hpp"
+#include "activemq/command/RemoveSubscriptionInfo.hpp"
+#include "activemq/command/SessionInfo.hpp"
+#include "activemq/command/TransactionInfo.hpp"
+#include "activemq/command/WireFormatInfo.hpp"
+#include "activemq/command/BrokerId.hpp"
+#include "activemq/command/ShutdownInfo.hpp"
+
+using namespace apache::activemq::command;
+
+/*
+ * 
+ */
+int AbstractCommand::getCommandId()
+{
+    return commandId ; 
+}
+
+/*
+ * 
+ */
+void AbstractCommand::setCommandId(int id)
+{
+    commandId = id ; 
+}
+
+/*
+ * 
+ */
+bool AbstractCommand::getResponseRequired()
+{
+    return responseRequired ;
+}
+
+/*
+ * 
+ */
+void AbstractCommand::setResponseRequired(bool value)
+{
+    responseRequired = value ;
+}
+
+/*
+ * 
+ */
+unsigned char AbstractCommand::getDataStructureType()
+{
+    return 0 ;
+}
+
+/*
+ * 
+ */
+bool AbstractCommand::isMarshallAware()
+{
+    return false ;
+}
+
+/*
+ * 
+ */
+int AbstractCommand::marshal(p<IMarshaller> marshaller, int mode, p<IOutputStream> writer) throw(IOException)
+{
+    return 0 ;
+}
+
+/*
+ * 
+ */
+void AbstractCommand::unmarshal(p<IMarshaller> marshaller, int mode, p<IInputStream> reader) throw(IOException)
+{
+}
+
+/*
+ * 
+ */
+p<IDataStructure> AbstractCommand::createObject(unsigned char type)
+ {
+    switch( type )
+    {
+        case ActiveMQMessage::TYPE:
+            return new ActiveMQMessage() ;
+        case ActiveMQTextMessage::TYPE:
+            return new ActiveMQTextMessage() ;
+        case ActiveMQObjectMessage::TYPE:
+            return new ActiveMQObjectMessage() ;
+        case ActiveMQBytesMessage::TYPE:
+            return new ActiveMQBytesMessage() ;
+        case ActiveMQStreamMessage::TYPE:
+            return new ActiveMQStreamMessage() ;
+        case ActiveMQMapMessage::TYPE:
+            return new ActiveMQMapMessage() ;
+        case ActiveMQQueue::TYPE:
+            return new ActiveMQQueue() ;
+        case ConsumerId::TYPE:
+            return new ConsumerId() ;
+        case ProducerId::TYPE:
+            return new ProducerId() ;
+        case MessageId::TYPE:
+            return new MessageId() ;
+        case LocalTransactionId::TYPE:
+            return new LocalTransactionId() ;
+        case MessageAck::TYPE:
+            return new MessageAck() ;
+        case MessageDispatch::TYPE:
+            return new MessageDispatch() ;
+        case Response::TYPE:
+            return new Response() ;
+        case ConsumerInfo::TYPE:
+            return new ConsumerInfo() ;
+        case ProducerInfo::TYPE:
+            return new ProducerInfo() ;
+        case TransactionInfo::TYPE:
+            return new TransactionInfo() ;
+        case BrokerInfo::TYPE:
+            return new BrokerInfo() ;
+        case BrokerId::TYPE:
+            return new BrokerId() ;
+        case ConnectionInfo::TYPE:
+            return new ConnectionInfo() ;
+        case SessionInfo::TYPE:
+            return new SessionInfo() ;
+        case RemoveSubscriptionInfo::TYPE:
+            return new RemoveSubscriptionInfo() ;
+        case IntegerResponse::TYPE:
+            return new IntegerResponse() ;
+        case WireFormatInfo::TYPE:
+            return new WireFormatInfo() ;
+        case RemoveInfo::TYPE:
+            return new RemoveInfo() ;
+        case KeepAliveInfo::TYPE:
+            return new KeepAliveInfo() ;
+        case ShutdownInfo::TYPE:
+            return new ShutdownInfo() ;
+        default:
+            return NULL ;
+    }
+ }
+
+/*
+ * 
+ */
+p<string> AbstractCommand::getDataStructureTypeAsString(unsigned char type)
+{
+    p<string> packetType = new string() ;
+
+    switch( type )
+    {
+        case ActiveMQMessage::TYPE:
+            packetType->assign("ACTIVEMQ_MESSAGE") ;
+            break ;
+        case ActiveMQTextMessage::TYPE:
+            packetType->assign("ACTIVEMQ_TEXT_MESSAGE") ;
+            break ;
+        case ActiveMQObjectMessage::TYPE:
+            packetType->assign("ACTIVEMQ_OBJECT_MESSAGE") ;
+            break ;
+        case ActiveMQBytesMessage::TYPE:
+            packetType->assign("ACTIVEMQ_BYTES_MESSAGE") ;
+            break ;
+        case ActiveMQStreamMessage::TYPE:
+            packetType->assign("ACTIVEMQ_STREAM_MESSAGE") ;
+            break ;
+        case ActiveMQMapMessage::TYPE:
+            packetType->assign("ACTIVEMQ_MAP_MESSAGE") ;
+            break ;
+        case ActiveMQQueue::TYPE:
+            packetType->assign("ACTIVEMQ_QUEUE") ;
+            break ;
+        case ConsumerId::TYPE:
+            packetType->assign("CONSUMER_ID") ;
+            break ;
+        case ProducerId::TYPE:
+            packetType->assign("PRODUCER_ID") ;
+            break ;
+        case MessageId::TYPE:
+            packetType->assign("MESSAGE_ID") ;
+            break ;
+        case LocalTransactionId::TYPE:
+            packetType->assign("LOCAL_TRANSACTION_ID") ;
+            break ;
+        case MessageAck::TYPE:
+            packetType->assign("ACTIVEMQ_MSG_ACK") ;
+            break ;
+        case MessageDispatch::TYPE:
+            packetType->assign("ACTIVEMQ_MSG_DISPATCH") ;
+            break ;
+        case Response::TYPE:
+            packetType->assign("RESPONSE") ;
+            break ;
+        case ConsumerInfo::TYPE:
+            packetType->assign("CONSUMER_INFO") ;
+            break ;
+        case ProducerInfo::TYPE:
+            packetType->assign("PRODUCER_INFO") ;
+            break;
+        case TransactionInfo::TYPE:
+            packetType->assign("TRANSACTION_INFO") ;
+            break ;
+        case BrokerInfo::TYPE:
+            packetType->assign("BROKER_INFO") ;
+            break ;
+        case ConnectionInfo::TYPE:
+            packetType->assign("CONNECTION_INFO") ;
+            break ;
+        case SessionInfo::TYPE:
+            packetType->assign("SESSION_INFO") ;
+            break ;
+        case RemoveSubscriptionInfo::TYPE:
+            packetType->assign("DURABLE_UNSUBSCRIBE") ;
+            break ;
+        case IntegerResponse::TYPE:
+            packetType->assign("INT_RESPONSE_RECEIPT_INFO") ;
+            break ;
+        case WireFormatInfo::TYPE:
+            packetType->assign("WIRE_FORMAT_INFO") ;
+            break ;
+        case RemoveInfo::TYPE:
+            packetType->assign("REMOVE_INFO") ;
+            break ;
+        case KeepAliveInfo::TYPE:
+            packetType->assign("KEEP_ALIVE") ;
+            break ;
+        case ShutdownInfo::TYPE:
+            packetType->assign("SHUTDOWN") ;
+            break ;
+        default:
+            packetType->assign("UNDEFINED") ;
+            break ;
+    }
+    return packetType ;
+}

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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.
+ */
+#ifndef ActiveMQ_AbstractCommand_hpp_
+#define ActiveMQ_AbstractCommand_hpp_
+
+#include <string>
+#include "activemq/ICommand.hpp"
+#include "activemq/IDataStructure.hpp"
+#include "ppr/io/IOutputStream.hpp"
+#include "ppr/io/IInputStream.hpp"
+#include "ppr/io/IOException.hpp"
+#include "ppr/util/ifr/p"
+
+namespace apache
+{
+  namespace activemq
+  {
+    namespace command
+    {
+      using namespace ifr;
+      using namespace std;
+      using namespace apache::activemq;
+      using namespace apache::ppr::io;
+
+/*
+ * 
+ */
+class AbstractCommand : public ICommand
+{
+protected:
+    int  commandId ;
+    bool responseRequired ;
+
+protected:
+    AbstractCommand() : commandId (0), responseRequired (false) {}
+public:
+    virtual int getCommandId() ;
+    virtual void setCommandId(int id) ;
+    virtual bool getResponseRequired() ;
+    virtual void setResponseRequired(bool value) ;
+    virtual unsigned char getDataStructureType() ;
+
+    virtual bool isMarshallAware() ;
+    virtual int marshal(p<IMarshaller> marshaller, int mode, p<IOutputStream> writer) throw(IOException) ;
+    virtual void unmarshal(p<IMarshaller> marshaller, int mode, p<IInputStream> reader) throw(IOException) ;
+
+    static p<IDataStructure> createObject(unsigned char type) ;
+    static p<string> getDataStructureTypeAsString(unsigned char type) ;
+} ;
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*ActiveMQ_AbstractCommand_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.cpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.cpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.cpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.cpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,406 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 "activemq/command/ActiveMQBytesMessage.hpp"
+
+using namespace apache::activemq::command;
+
+
+/*
+ * 
+ */
+ActiveMQBytesMessage::ActiveMQBytesMessage()
+{
+    this->in       = NULL ;
+    this->out      = new ByteArrayOutputStream() ;
+    this->readMode = false ;
+}
+
+/*
+ * 
+ */
+ActiveMQBytesMessage::ActiveMQBytesMessage(char* body, int size)
+{
+    // Convert body to SP array
+    array<char> buffer = array<char> (size) ;
+    memcpy(buffer.c_array(), body, size);
+
+    this->in       = NULL ;
+    this->out      = new ByteArrayOutputStream(buffer) ;
+    this->readMode = false ;
+}
+
+/*
+ * 
+ */
+ActiveMQBytesMessage::~ActiveMQBytesMessage()
+{
+}
+
+/*
+ * 
+ */
+unsigned char ActiveMQBytesMessage::getDataStructureType()
+{
+    return ActiveMQBytesMessage::TYPE ;
+}
+
+/*
+ *
+ */
+void ActiveMQBytesMessage::reset()
+{
+    if( !readMode )
+    {
+        this->in       = new ByteArrayInputStream( out->toArray() ) ;
+        this->out      = NULL ;
+        this->readMode = true ;
+    }
+}
+
+/*
+ *
+ */
+char ActiveMQBytesMessage::readByte() throw(MessageNotReadableException, MessageEOFException)
+{
+    // Assert read mode
+    if( !readMode )
+        throw MessageNotReadableException() ;
+
+    try
+    {
+        // Read a single byte
+        return readByte() ;
+    }
+    catch( EOFException eof )
+    {
+        throw MessageEOFException() ;
+    }
+}
+
+/*
+ *
+ */
+int ActiveMQBytesMessage::readBytes(char* buffer, int index, int length) throw (MessageNotReadableException, MessageEOFException)
+{
+    // Assert read mode
+    if( !readMode )
+        throw MessageNotReadableException() ;
+
+    try
+    {
+        // Read some bytes
+        return in->read(buffer, index, length) ;
+    }
+    catch( EOFException eof )
+    {
+        throw MessageEOFException() ;
+    }
+}
+
+/*
+ *
+ */
+bool ActiveMQBytesMessage::readBoolean() throw(MessageNotReadableException, MessageEOFException)
+{
+    // Assert read mode
+    if( !readMode )
+        throw MessageNotReadableException() ;
+
+    try
+    {
+        // Read a boolean
+        return in->readBoolean() ;
+    }
+    catch( EOFException eof )
+    {
+        throw MessageEOFException() ;
+    }
+}
+
+/*
+ *
+ */
+double ActiveMQBytesMessage::readDouble() throw(MessageNotReadableException, MessageEOFException)
+{
+    // Assert read mode
+    if( !readMode )
+        throw MessageNotReadableException() ;
+
+    try
+    {
+        // Read a double
+        return in->readDouble() ;
+    }
+    catch( EOFException eof )
+    {
+        throw MessageEOFException() ;
+    }
+}
+
+/*
+ *
+ */
+float ActiveMQBytesMessage::readFloat() throw(MessageNotReadableException, MessageEOFException)
+{
+    // Assert read mode
+    if( !readMode )
+        throw MessageNotReadableException() ;
+
+    try
+    {
+        // Read a float
+        return in->readFloat() ;
+    }
+    catch( EOFException eof )
+    {
+        throw MessageEOFException() ;
+    }
+}
+
+/*
+ *
+ */
+short ActiveMQBytesMessage::readShort() throw(MessageNotReadableException, MessageEOFException)
+{
+    // Assert read mode
+    if( !readMode )
+        throw MessageNotReadableException() ;
+
+    try
+    {
+        // Read a short
+        return in->readShort() ;
+    }
+    catch( EOFException eof )
+    {
+        throw MessageEOFException() ;
+    }
+}
+
+/*
+ *
+ */
+int ActiveMQBytesMessage::readInt() throw(MessageNotReadableException, MessageEOFException)
+{
+    // Assert read mode
+    if( !readMode )
+        throw MessageNotReadableException() ;
+
+    try
+    {
+        // Read an integer
+        return in->readInt() ;
+    }
+    catch( EOFException eof )
+    {
+        throw MessageEOFException() ;
+    }
+}
+
+/*
+ *
+ */
+long long ActiveMQBytesMessage::readLong() throw(MessageNotReadableException, MessageEOFException)
+{
+    // Assert read mode
+    if( !readMode )
+        throw MessageNotReadableException() ;
+
+    try
+    {
+        // Read a long long
+        return in->readLong() ;
+    }
+    catch( EOFException eof )
+    {
+        throw MessageEOFException() ;
+    }
+}
+
+/*
+ *
+ */
+p<string> ActiveMQBytesMessage::readUTF() throw(MessageNotReadableException, MessageEOFException)
+{
+    // Assert read mode
+    if( !readMode )
+        throw MessageNotReadableException() ;
+
+    try
+    {
+        // Read a string
+        return in->readString() ;
+    }
+    catch( EOFException eof )
+    {
+        throw MessageEOFException() ;
+    }
+}
+
+/*
+ * 
+ */
+void ActiveMQBytesMessage::writeByte(char value) throw (MessageNotWritableException)
+{
+    // Assert write mode
+    if( readMode )
+        throw MessageNotWritableException() ;
+
+    // Write a single byte
+    out->writeByte(value) ;
+}
+
+/*
+ * 
+ */
+void ActiveMQBytesMessage::writeBytes(char* value, int index, int length) throw (MessageNotWritableException)
+{
+    // Assert write mode
+    if( readMode )
+        throw MessageNotWritableException() ;
+
+    // Write some bytes
+    out->write(value, index, length) ;
+}
+
+/*
+ * 
+ */
+void ActiveMQBytesMessage::writeBoolean(bool value) throw (MessageNotWritableException)
+{
+    // Assert write mode
+    if( readMode )
+        throw MessageNotWritableException() ;
+
+    // Write a boolean
+    out->writeBoolean(value) ;
+}
+
+/*
+ * 
+ */
+void ActiveMQBytesMessage::writeDouble(double value) throw (MessageNotWritableException)
+{
+    // Assert write mode
+    if( readMode )
+        throw MessageNotWritableException() ;
+
+    // Write a double
+    out->writeDouble(value) ;
+}
+
+/*
+ * 
+ */
+void ActiveMQBytesMessage::writeFloat(float value) throw (MessageNotWritableException)
+{
+    // Assert write mode
+    if( readMode )
+        throw MessageNotWritableException() ;
+
+    // Write a float
+    out->writeFloat(value) ;
+}
+
+/*
+ * 
+ */
+void ActiveMQBytesMessage::writeInt(int value) throw (MessageNotWritableException)
+{
+    // Assert write mode
+    if( readMode )
+        throw MessageNotWritableException() ;
+
+    // Write an integer
+    out->writeInt(value) ;
+}
+
+/*
+ * 
+ */
+void ActiveMQBytesMessage::writeLong(long long value) throw (MessageNotWritableException)
+{
+    // Assert write mode
+    if( readMode )
+        throw MessageNotWritableException() ;
+
+    // Write a long long
+    out->writeLong(value) ;
+}
+
+/*
+ * 
+ */
+void ActiveMQBytesMessage::writeShort(short value) throw (MessageNotWritableException)
+{
+    // Assert write mode
+    if( readMode )
+        throw MessageNotWritableException() ;
+
+    // Write a short
+    out->writeShort(value) ;
+}
+
+/*
+ * 
+ */
+void ActiveMQBytesMessage::writeUTF(const char* value) throw (MessageNotWritableException)
+{
+    // Assert write mode
+    if( readMode )
+        throw MessageNotWritableException() ;
+
+    // Write a string
+    p<string> v = new string(value) ;
+    out->writeString(v) ;
+}
+
+/*
+ *
+ */
+int ActiveMQBytesMessage::marshal(p<IMarshaller> marshaller, int mode, p<IOutputStream> writer) throw (IOException)
+{
+    int size = 0 ;
+
+    // Copy body to message content container
+    if( mode == IMarshaller::MARSHAL_SIZE )
+        this->content = ( readMode) ? in->toArray() : out->toArray() ;
+
+//    size += (int)this->content.size() ;
+    size += ActiveMQMessage::marshal(marshaller, mode, writer) ;
+
+    // Note! Message content marshalling is done in super class
+
+    return size ;
+}
+
+/*
+ *
+ */
+void ActiveMQBytesMessage::unmarshal(p<IMarshaller> marshaller, int mode, p<IInputStream> reader) throw (IOException)
+{
+    // Note! Message content unmarshalling is done in super class
+    ActiveMQMessage::unmarshal(marshaller, mode, reader) ;
+
+    // Copy body to message content holder
+    if( mode == IMarshaller::MARSHAL_READ )
+    {
+        in       = new ByteArrayInputStream( this->content ) ;
+        out      = NULL ;
+        readMode = true ;
+    }
+}

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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.
+ */
+#ifndef ActiveMQ_ActiveMQBytesMessage_hpp_
+#define ActiveMQ_ActiveMQBytesMessage_hpp_
+
+// Turn off warning message for ignored exception specification
+#ifdef _MSC_VER
+#pragma warning( disable : 4290 )
+#endif
+
+#include <map>
+#include <string>
+#include "cms/IBytesMessage.hpp"
+#include "cms/MessageEOFException.hpp"
+#include "cms/MessageNotWritableException.hpp"
+#include "activemq/command/ActiveMQMessage.hpp"
+#include "ppr/io/ByteArrayInputStream.hpp"
+#include "ppr/io/ByteArrayOutputStream.hpp"
+#include "ppr/io/EOFException.hpp"
+#include "ppr/util/Endian.hpp"
+#include "ppr/util/MapItemHolder.hpp"
+#include "ppr/util/ifr/array"
+#include "ppr/util/ifr/p"
+
+namespace apache
+{
+  namespace activemq
+  {
+    namespace command
+    {
+      using namespace ifr;
+      using namespace apache::cms;
+      using namespace apache::ppr::io;
+      using namespace apache::ppr::util;
+
+/*
+ * 
+ */
+class ActiveMQBytesMessage : public ActiveMQMessage , public IBytesMessage
+{
+private:
+    p<ByteArrayInputStream>  in ;
+    p<ByteArrayOutputStream> out ;
+    bool  readMode ;
+
+    const static int INITIAL_SIZE = 256 ;
+    const static int EXPAND_SIZE  = 128 ;
+
+public:
+    const static unsigned char TYPE = 24 ;
+
+public:
+    ActiveMQBytesMessage() ;
+    ActiveMQBytesMessage(char* body, int size) ;
+    virtual ~ActiveMQBytesMessage() ;
+
+    virtual unsigned char getDataStructureType() ;
+
+    virtual void reset() ;
+    virtual char readByte() throw (MessageNotReadableException, MessageEOFException) ;
+    virtual int readBytes(char* buffer, int index, int length) throw (MessageNotReadableException, MessageEOFException) ;
+    virtual bool readBoolean() throw (MessageNotReadableException, MessageEOFException) ;
+    virtual double readDouble() throw (MessageNotReadableException, MessageEOFException) ;
+    virtual float readFloat() throw (MessageNotReadableException, MessageEOFException) ;
+    virtual int readInt() throw (MessageNotReadableException, MessageEOFException) ;
+    virtual long long readLong() throw (MessageNotReadableException, MessageEOFException) ;
+    virtual short readShort() throw (MessageNotReadableException, MessageEOFException) ;
+    virtual p<string> readUTF() throw (MessageNotReadableException, MessageEOFException) ;
+    virtual void writeBoolean(bool value) throw (MessageNotWritableException) ;
+    virtual void writeByte(char value) throw (MessageNotWritableException) ;
+    virtual void writeBytes(char* value, int index, int length) throw (MessageNotWritableException) ;
+    virtual void writeDouble(double value) throw (MessageNotWritableException) ;
+    virtual void writeFloat(float value) throw (MessageNotWritableException) ;
+    virtual void writeInt(int value) throw (MessageNotWritableException) ;
+    virtual void writeLong(long long value) throw (MessageNotWritableException) ;
+    virtual void writeShort(short value) throw (MessageNotWritableException) ;
+    virtual void writeUTF(const char* value) throw (MessageNotWritableException) ;
+
+    virtual int marshal(p<IMarshaller> marshaller, int mode, p<IOutputStream> writer) throw (IOException) ;
+    virtual void unmarshal(p<IMarshaller> marshaller, int mode, p<IInputStream> reader) throw (IOException) ;
+
+    //
+    // The methods below are needed to resolve the multiple
+    // inheritance of IMessage.
+    virtual void acknowledge() {
+        ActiveMQMessage::acknowledge() ;
+    } ;
+    virtual p<PropertyMap> getProperties() {
+        return ActiveMQMessage::getProperties() ;
+    } ;
+    virtual p<string> getJMSCorrelationID() {
+        return ActiveMQMessage::getJMSCorrelationID() ;
+    } ;
+    virtual void setJMSCorrelationID(const char* correlationId) {
+        return ActiveMQMessage::setJMSCorrelationID(correlationId) ;
+    } ;
+    virtual p<IDestination> getJMSDestination() {
+        return ActiveMQMessage::getJMSDestination() ;
+    } ;
+    virtual long long getJMSExpiration() {
+        return ActiveMQMessage::getJMSExpiration() ;
+    } ;
+    virtual void setJMSExpiration(long long time) {
+        return ActiveMQMessage::setJMSExpiration(time) ;
+    } ;
+    virtual p<string> getJMSMessageID() {
+        return ActiveMQMessage::getJMSMessageID() ;
+    } ;
+    virtual bool getJMSPersistent() {
+        return ActiveMQMessage::getJMSPersistent() ;
+    } ;
+    virtual void setJMSPersistent(bool persistent) {
+        return ActiveMQMessage::setJMSPersistent(persistent) ;
+    } ;
+    virtual unsigned char getJMSPriority() {
+        return ActiveMQMessage::getJMSPriority() ;
+    } ;
+    virtual void setJMSPriority(unsigned char priority) {
+        return ActiveMQMessage::setJMSPriority(priority) ;
+    } ;
+    virtual bool getJMSRedelivered() {
+        return ActiveMQMessage::getJMSRedelivered() ;
+    } ;
+    virtual p<IDestination> getJMSReplyTo() {
+        return ActiveMQMessage::getJMSReplyTo() ;
+    } ;
+    virtual void setJMSReplyTo(p<IDestination> destination) {
+        return ActiveMQMessage::setJMSReplyTo(destination) ;
+    } ;
+    virtual long long getJMSTimestamp() {
+        return ActiveMQMessage::getJMSTimestamp() ;
+    } ;
+    virtual p<string> getJMSType() {
+        return ActiveMQMessage::getJMSType() ;
+    } ;
+    virtual void setJMSType(const char* type) {
+        return ActiveMQMessage::setJMSType(type) ;
+    } ;
+    virtual int getJMSXDeliveryCount() {
+        return ActiveMQMessage::getJMSXDeliveryCount() ;
+    } ;
+    virtual p<string> getJMSXGroupID() {
+        return ActiveMQMessage::getJMSXGroupID() ;
+    } ;
+    virtual void setJMSXGroupID(const char* groupId) {
+        return ActiveMQMessage::setJMSXGroupID(groupId) ;
+    } ;
+    virtual int getJMSXGroupSeq() {
+        return ActiveMQMessage::getJMSXGroupSeq() ;
+    } ;
+    virtual void setJMSXGroupSeq(int sequence) {
+        return ActiveMQMessage::setJMSXGroupSeq(sequence) ;
+    } ;
+    virtual p<string> getJMSXProducerTxID() {
+        return ActiveMQMessage::getJMSXProducerTxID() ;
+    } ;
+
+//private:
+  //  void expandBody() ;
+} ;
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*ActiveMQ_ActiveMQBytesMessage_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.cpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.cpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.cpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.cpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,364 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 "activemq/DestinationFilter.hpp"
+#include "activemq/command/ActiveMQDestination.hpp"
+#include "activemq/command/ActiveMQTempQueue.hpp"
+#include "activemq/command/ActiveMQTempTopic.hpp"
+#include "activemq/command/ActiveMQQueue.hpp"
+#include "activemq/command/ActiveMQTopic.hpp"
+
+using namespace apache::activemq::command;
+
+
+// --- Static initialization ----------------------------------------
+
+const char* ActiveMQDestination::ADVISORY_PREFIX            = "ActiveMQ.Advisory." ;
+const char* ActiveMQDestination::CONSUMER_ADVISORY_PREFIX   = "ActiveMQ.Advisory.Consumers." ;
+const char* ActiveMQDestination::PRODUCER_ADVISORY_PREFIX   = "ActiveMQ.Advisory.Producers." ;
+const char* ActiveMQDestination::CONNECTION_ADVISORY_PREFIX = "ActiveMQ.Advisory.Connections." ;
+const char* ActiveMQDestination::DEFAULT_ORDERED_TARGET     = "coordinator" ;
+
+const char* ActiveMQDestination::TEMP_PREFIX         = "{TD{" ;
+const char* ActiveMQDestination::TEMP_POSTFIX        = "}TD}" ;
+const char* ActiveMQDestination::COMPOSITE_SEPARATOR = "," ;
+const char* ActiveMQDestination::QUEUE_PREFIX        = "queue://" ;
+const char* ActiveMQDestination::TOPIC_PREFIX        = "topic://" ;
+
+
+/*
+ * Default constructor
+ */
+ActiveMQDestination::ActiveMQDestination()
+{
+    orderedTarget = new string(DEFAULT_ORDERED_TARGET) ;
+    physicalName  = new string("") ;
+    exclusive     = false ;
+    ordered       = false ;
+    advisory      = false ;
+}
+
+/*
+ * Constructs the destination with a specified physical name.
+ *
+ * @param   name the physical name for the destination.
+ */
+ActiveMQDestination::ActiveMQDestination(const char* name)
+{
+    orderedTarget = new string(DEFAULT_ORDERED_TARGET) ;
+    physicalName  = new string(name) ;
+    exclusive     = false ;
+    ordered       = false ;
+    advisory      = ( name != NULL && (physicalName->find(ADVISORY_PREFIX) == 0)) ? true : false ;
+}
+
+/*
+ *
+ */
+ActiveMQDestination::~ActiveMQDestination()
+{
+    // no-op
+}
+
+/*
+ *
+ */
+bool ActiveMQDestination::isAdvisory()
+{
+    return advisory ;
+}
+
+/*
+ *
+ */
+void ActiveMQDestination::setAdvisory(bool advisory)
+{
+    this->advisory = advisory ;
+}
+
+/*
+ *
+ */
+bool ActiveMQDestination::isConsumerAdvisory()
+{
+    return ( isAdvisory() && (physicalName->find(CONSUMER_ADVISORY_PREFIX) == 0) ) ;
+}
+
+/*
+ *
+ */
+bool ActiveMQDestination::isProducerAdvisory()
+{
+    return ( isAdvisory() && (physicalName->find(PRODUCER_ADVISORY_PREFIX) == 0) ) ;
+}
+
+/*
+ *
+ */
+bool ActiveMQDestination::isConnectionAdvisory()
+{
+    return ( isAdvisory() && (physicalName->find(CONNECTION_ADVISORY_PREFIX) == 0) ) ;
+}
+
+/*
+ *
+ */
+bool ActiveMQDestination::isExclusive()
+{
+    return exclusive ;
+}
+
+/*
+ *
+ */
+void ActiveMQDestination::setExclusive(bool exclusive)
+{
+    this->exclusive = exclusive ;
+}
+
+/*
+ *
+ */
+bool ActiveMQDestination::isOrdered()
+{
+    return ordered ;
+}
+
+/*
+ *
+ */
+void ActiveMQDestination::setOrdered(bool ordered)
+{
+    this->ordered = ordered ;
+}
+
+/*
+ *
+ */
+p<string> ActiveMQDestination::getOrderedTarget()
+{
+    return orderedTarget ;
+}
+
+/*
+ *
+ */
+void ActiveMQDestination::setOrderedTarget(const char* target)
+{
+    this->orderedTarget->assign(target) ;
+}
+
+/*
+ *
+ */
+p<string> ActiveMQDestination::getPhysicalName()
+{
+    return physicalName ;
+}
+
+/*
+ *
+ */
+void ActiveMQDestination::setPhysicalName(const char* name)
+{
+    physicalName->assign(name) ;
+}
+
+/*
+ *
+ */
+bool ActiveMQDestination::isTopic()
+{
+    return ( getDestinationType() == ACTIVEMQ_TOPIC ||
+             getDestinationType() == ACTIVEMQ_TEMPORARY_TOPIC ) ; 
+}
+
+/*
+ *
+ */
+bool ActiveMQDestination::isQueue()
+{
+    return !isTopic() ;
+}
+
+/*
+ *
+ */
+bool ActiveMQDestination::isTemporary()
+{
+    return ( getDestinationType() == ACTIVEMQ_TEMPORARY_TOPIC ||
+             getDestinationType() == ACTIVEMQ_TEMPORARY_QUEUE ) ; 
+}
+
+/*
+ *
+ */
+bool ActiveMQDestination::isComposite()
+{
+    return ( physicalName->find(ActiveMQDestination::COMPOSITE_SEPARATOR) > 0 ) ;
+}
+
+/*
+ *
+ */
+bool ActiveMQDestination::isWildcard()
+{
+    if( physicalName != NULL )
+    {
+        return ( physicalName->find( DestinationFilter::ANY_CHILD ) >= 0 ||
+                 physicalName->find( DestinationFilter::ANY_DESCENDENT ) >= 0 ) ;
+    }
+    return false ;
+}
+
+/*
+ *
+ */
+p<string> ActiveMQDestination::toString()
+{
+    return physicalName ;
+}
+
+// --- Static methods ---------------------------------------------
+
+/*
+ * A helper method to return a descriptive string for the topic or queue.
+ */
+p<string> ActiveMQDestination::inspect(p<ActiveMQDestination> destination)
+{
+    p<string> description = new string() ;
+
+    if( typeid(*destination) == typeid(ITopic) )
+        description->assign("Topic(") ;
+    else
+        description->assign("Queue(") ;
+    
+    description->append( destination->toString()->c_str() ) ;
+    description->append(")") ;
+
+    return description ;
+}
+
+/*
+ *
+ */
+/*p<ActiveMQDestination> ActiveMQDestination::transform(p<IDestination> destination)
+{
+    p<ActiveMQDestination> result = NULL ;
+
+    if( destination != NULL )
+    {
+        if( typeid(*destination) == typeid(ActiveMQDestination) )
+            result = p_cast<ActiveMQDestination> (destination) ;
+
+        else
+        {
+            if( typeid(ITopic).before(typeid(IDestination)) )
+                result = new ActiveMQTopic( (p_cast<ITopic> (destination))->getTopicName()->c_str() ) ;
+
+            else if( typeid(*destination).before(typeid(IQueue)) )
+                result = new ActiveMQQueue( (p_cast<IQueue> (destination))->getQueueName()->c_str() ) ;
+
+            else if( typeid(ITemporaryQueue).before(typeid(*destination)) )
+                result = new ActiveMQTempQueue( (p_cast<IQueue> (destination))->getQueueName()->c_str() ) ;
+
+            else if( typeid(ITemporaryTopic).before(typeid(*destination)) )
+                result = new ActiveMQTempTopic( (p_cast<ITopic> (destination))->getTopicName()->c_str() ) ;
+
+        } 
+    }
+    return result ;
+}*/
+
+/*
+ *
+ */
+p<ActiveMQDestination> ActiveMQDestination::createDestination(int type, const char* physicalName)
+{
+    p<ActiveMQDestination> result = NULL ;
+
+    if( type == ActiveMQDestination::ACTIVEMQ_TOPIC )
+        result = new ActiveMQTopic(physicalName) ;
+
+    else if( type == ActiveMQDestination::ACTIVEMQ_TEMPORARY_TOPIC )
+        result = new ActiveMQTempTopic(physicalName) ;
+
+    else if (type == ActiveMQDestination::ACTIVEMQ_QUEUE)
+        result = new ActiveMQQueue(physicalName) ;
+
+    else
+        result = new ActiveMQTempQueue(physicalName) ;
+
+    return result ;
+}
+
+/*
+ *
+ */
+p<string> ActiveMQDestination::createTemporaryName(const char* clientId)
+{
+    p<string> tempName = new string() ;
+
+    tempName->assign( ActiveMQDestination::TEMP_PREFIX ) ;
+    tempName->append(clientId) ;
+    tempName->append( ActiveMQDestination::TEMP_POSTFIX ) ;
+
+    return tempName ;
+}
+
+/*
+ *
+ */
+p<string> ActiveMQDestination::getClientId(p<ActiveMQDestination> destination)
+{
+    p<string> answer = NULL ;
+
+    if( destination != NULL && destination->isTemporary() )
+    {
+        p<string> name = destination->getPhysicalName() ;
+        int      start = (int)name->find(TEMP_PREFIX),
+                 stop ;
+
+        if( start >= 0 )
+        {
+            start += (int)strlen(TEMP_PREFIX) ;
+            stop   = (int)name->find_last_of(TEMP_POSTFIX) ;
+
+            if( stop > start && stop < (int)name->length() )
+                answer->assign( name->substr(start, stop) ) ;
+        } 
+    }
+    return answer; 
+}
+
+/*
+ *
+ */
+int ActiveMQDestination::marshal(p<IMarshaller> marshaller, int mode, p<IOutputStream> writer) throw (IOException)
+{
+    int size = 0 ;
+
+    size += marshaller->marshalString(physicalName, mode, writer) ; 
+    return size ;
+}
+
+/*
+ *
+ */
+void ActiveMQDestination::unmarshal(p<IMarshaller> marshaller, int mode, p<IInputStream> reader) throw (IOException)
+{
+    physicalName = p_cast<string>(marshaller->unmarshalString(mode, reader)) ; 
+}

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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.
+ */
+#ifndef ActiveMQ_ActiveMQDestination_hpp_
+#define ActiveMQ_ActiveMQDestination_hpp_
+
+#include <typeinfo>
+#include "cms/IDestination.hpp"
+#include "cms/ITopic.hpp"
+#include "cms/IQueue.hpp"
+#include "cms/ITemporaryTopic.hpp"
+#include "cms/ITemporaryQueue.hpp"
+#include "activemq/command/AbstractCommand.hpp"
+#include "activemq/protocol/IMarshaller.hpp"
+#include "ppr/io/IOutputStream.hpp"
+#include "ppr/io/IInputStream.hpp"
+#include "ppr/io/IOException.hpp"
+#include "ppr/util/ifr/p"
+
+namespace apache
+{
+  namespace activemq
+  {
+    namespace command
+    {
+      using namespace ifr;
+      using namespace apache::activemq;
+      using namespace apache::activemq::protocol;
+      using namespace apache::cms;
+      using namespace apache::ppr::io;
+      class ActiveMQQueue ;
+      class ActiveMQTempQueue ;
+      class ActiveMQTopic ;
+      class ActiveMQTempTopic ;
+
+/*
+ * 
+ */
+class ActiveMQDestination : public AbstractCommand, public IDestination
+{
+private:
+    p<string> orderedTarget,
+              physicalName ;
+    bool      exclusive,
+              ordered,
+              advisory ;
+
+    // Prefix/postfix for queue/topic names
+    static const char* TEMP_PREFIX ;
+    static const char* TEMP_POSTFIX ;
+    static const char* COMPOSITE_SEPARATOR ;
+    static const char* QUEUE_PREFIX ;
+    static const char* TOPIC_PREFIX ;
+
+public:
+    // Destination type constants
+    static const int ACTIVEMQ_TOPIC           = 1 ;
+    static const int ACTIVEMQ_TEMPORARY_TOPIC = 2 ;
+    static const int ACTIVEMQ_QUEUE           = 3 ;
+    static const int ACTIVEMQ_TEMPORARY_QUEUE = 4 ;
+
+    // Prefixes for Advisory message destinations
+    static const char* ADVISORY_PREFIX ;
+    static const char* CONSUMER_ADVISORY_PREFIX ;
+    static const char* PRODUCER_ADVISORY_PREFIX ;
+    static const char* CONNECTION_ADVISORY_PREFIX ;
+
+    // The default target for ordered destinations
+    static const char* DEFAULT_ORDERED_TARGET ;
+
+protected:
+    ActiveMQDestination() ;
+    ActiveMQDestination(const char* name) ;
+
+public:
+    virtual ~ActiveMQDestination() ;
+
+    // Attributes methods
+    virtual bool isAdvisory() ;
+    virtual void setAdvisory(bool advisory) ;
+    virtual bool isConsumerAdvisory() ;
+    virtual bool isProducerAdvisory() ;
+    virtual bool isConnectionAdvisory() ;
+    virtual bool isExclusive() ;
+    virtual void setExclusive(bool exclusive) ;
+    virtual bool isOrdered() ;
+    virtual void setOrdered(bool ordered) ;
+    virtual p<string> getOrderedTarget() ;
+    virtual void setOrderedTarget(const char* target) ;
+    virtual p<string> getPhysicalName() ;
+    virtual void setPhysicalName(const char* name) ;
+    virtual bool isTopic() ;
+    virtual bool isQueue() ;
+    virtual bool isTemporary() ;
+    virtual bool isComposite() ;
+    virtual bool isWildcard() ;
+    virtual p<string> toString() ;
+
+    virtual int marshal(p<IMarshaller> marshaller, int mode, p<IOutputStream> writer) throw (IOException) ;
+    virtual void unmarshal(p<IMarshaller> marshaller, int mode, p<IInputStream> reader) throw (IOException) ;
+
+    //
+    // Abstract methods
+
+    // Factory method to create a child destination if this destination is a composite.
+    virtual p<ActiveMQDestination> createDestination(const char* name) = 0 ;
+    virtual int getDestinationType() = 0 ;
+
+    //
+    // Static methods
+
+    static p<string> inspect(p<ActiveMQDestination> destination) ;
+    //static p<ActiveMQDestination> transform(p<IDestination> destination) ;
+    static p<ActiveMQDestination> createDestination(int type, const char* physicalName) ;
+    static p<string> createTemporaryName(const char* clientId) ;
+    static p<string> getClientId(p<ActiveMQDestination> destination) ;
+} ;
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*ActiveMQ_ActiveMQDestination_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.cpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.cpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.cpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.cpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,495 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 "activemq/command/ActiveMQMapMessage.hpp"
+#include "ppr/io/ByteArrayOutputStream.hpp"
+#include "ppr/io/ByteArrayInputStream.hpp"
+
+using namespace apache::activemq::command;
+
+/*
+ * 
+ */
+ActiveMQMapMessage::ActiveMQMapMessage()
+{
+    contentMap = new PropertyMap() ;
+}
+
+/*
+ * 
+ */
+ActiveMQMapMessage::~ActiveMQMapMessage()
+{
+}
+
+/*
+ * 
+ */
+unsigned char ActiveMQMapMessage::getDataStructureType()
+{
+    return ActiveMQMapMessage::TYPE ;
+}
+
+/*
+ * 
+ */
+p<PropertyMap> ActiveMQMapMessage::getBody()
+{
+    return contentMap ;
+}
+
+/*
+ * 
+ */
+bool ActiveMQMapMessage::getBoolean(const char* name) throw (MessageFormatException, IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    PropertyMap::iterator tempIter ;
+    string key = string(name) ;
+
+    // Check if key exists in map
+    tempIter = contentMap->find(key) ;
+    if( tempIter == contentMap->end() )
+        throw MessageFormatException("No boolean value available for given key") ;
+
+    try
+    {
+        // Try to get value as a boolean
+        return tempIter->second.getBoolean() ;
+    }
+    catch( ConversionException ce )
+    {
+        throw MessageFormatException( ce.what() ) ;
+    }
+}
+
+/*
+ * 
+ */
+void ActiveMQMapMessage::setBoolean(const char* name, bool value) throw (IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    string key = name ;
+    //contentMap->insert (pair<string,p<MapItemHolder> > (key, new MapItemHolder(value)));
+    (*contentMap)[key] = MapItemHolder(value);
+}
+
+/*
+ * 
+ */
+char ActiveMQMapMessage::getByte(const char* name) throw (MessageFormatException, IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    PropertyMap::iterator tempIter ;
+    string key = string(name) ;
+
+    // Check if key exists in map
+    tempIter = contentMap->find(key) ;
+    if( tempIter == contentMap->end() )
+        throw MessageFormatException("No byte value available for given key") ;
+
+    try
+    {
+        // Try to get value as a byte
+        return tempIter->second.getByte() ;
+    }
+    catch( ConversionException ce )
+    {
+        throw MessageFormatException( ce.what() ) ;
+    }
+}
+
+/*
+ * 
+ */
+void ActiveMQMapMessage::setByte(const char* name, char value) throw (IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    string key = name ;
+    (*contentMap)[key] = MapItemHolder(value);
+}
+
+/*
+ * 
+ */
+array<char> ActiveMQMapMessage::getBytes(const char* name) throw (MessageFormatException, IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    PropertyMap::iterator tempIter ;
+    string key = string(name) ;
+
+    // Check if key exists in map
+    tempIter = contentMap->find(key) ;
+    if( tempIter == contentMap->end() )
+        throw MessageFormatException("No byte array value available for given key") ;
+
+    try
+    {
+        // Try to get value as a byte array
+        return tempIter->second.getBytes() ;
+    }
+    catch( ConversionException ce )
+    {
+        throw MessageFormatException( ce.what() ) ;
+    }
+}
+
+/*
+ * 
+ */
+void ActiveMQMapMessage::setBytes(const char* name, array<char> value) throw (IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    string key = name ;
+    (*contentMap)[key] = MapItemHolder(value);
+}
+
+/*
+ * 
+ */
+double ActiveMQMapMessage::getDouble(const char* name) throw (MessageFormatException, IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    PropertyMap::iterator tempIter ;
+    string key = name ;
+
+    // Check if key exists in map
+    tempIter = contentMap->find(key) ;
+    if( tempIter == contentMap->end() )
+        throw MessageFormatException("No double value available for given key") ;
+
+    try
+    {
+        // Try to get value as a double
+        return tempIter->second.getDouble() ;
+    }
+    catch( ConversionException ce )
+    {
+        throw MessageFormatException( ce.what() ) ;
+    }
+}
+
+/*
+ * 
+ */
+void ActiveMQMapMessage::setDouble(const char* name, double value) throw (IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    string key = name ;
+    (*contentMap)[key] = MapItemHolder(value) ;
+}
+
+/*
+ * 
+ */
+float ActiveMQMapMessage::getFloat(const char* name) throw (MessageFormatException, IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    PropertyMap::iterator tempIter ;
+    string key = name ;
+
+    // Check if key exists in map
+    tempIter = contentMap->find(key) ;
+    if( tempIter == contentMap->end() )
+        throw MessageFormatException("No float value available for given key") ;
+
+    try
+    {
+        // Try to get value as a float
+        return tempIter->second.getFloat() ;
+    }
+    catch( ConversionException ce )
+    {
+        throw MessageFormatException( ce.what() ) ;
+    }
+}
+
+/*F
+ * 
+ */
+void ActiveMQMapMessage::setFloat(const char* name, float value) throw (IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    string key = name ;
+    (*contentMap)[key] = MapItemHolder(value) ;
+}
+
+/*
+ * 
+ */
+int ActiveMQMapMessage::getInt(const char* name) throw (MessageFormatException, IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    PropertyMap::iterator tempIter ;
+    string key = name ;
+
+    // Check if key exists in map
+    tempIter = contentMap->find(key) ;
+    if( tempIter == contentMap->end() )
+        throw MessageFormatException("No integer value available for given key") ;
+
+    try
+    {
+        // Try to get value as an integer
+        return tempIter->second.getInt() ;
+    }
+    catch( ConversionException ce )
+    {
+        throw MessageFormatException( ce.what() ) ;
+    }
+}
+
+/*
+ * 
+ */
+void ActiveMQMapMessage::setInt(const char* name, int value) throw (IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    string key = name ;
+    (*contentMap)[key] = MapItemHolder(value) ;
+}
+
+/*
+ * 
+ */
+long long ActiveMQMapMessage::getLong(const char* name) throw (MessageFormatException, IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    PropertyMap::iterator tempIter ;
+    string key = name ;
+
+    // Check if key exists in map
+    tempIter = contentMap->find(key) ;
+    if( tempIter == contentMap->end() )
+        throw MessageFormatException("No long value available for given key") ;
+
+    try
+    {
+        // Try to get value as a long
+        return tempIter->second.getLong() ;
+    }
+    catch( ConversionException ce )
+    {
+        throw MessageFormatException( ce.what() ) ;
+    }
+}
+
+/*
+ * 
+ */
+void ActiveMQMapMessage::setLong(const char* name, long long value) throw (IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    string key = name ;
+    (*contentMap)[key] = MapItemHolder(value) ;
+}
+
+/*
+ * 
+ */
+short ActiveMQMapMessage::getShort(const char* name) throw (MessageFormatException, IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    PropertyMap::iterator tempIter ;
+    string key = name ;
+
+    // Check if key exists in map
+    tempIter = contentMap->find(key) ;
+    if( tempIter == contentMap->end() )
+        throw MessageFormatException("No short value available for given key") ;
+
+    try
+    {
+        // Try to get value as a short
+        return tempIter->second.getShort() ;
+    }
+    catch( ConversionException ce )
+    {
+        throw MessageFormatException( ce.what() ) ;
+    }
+}
+
+/*
+ * 
+ */
+void ActiveMQMapMessage::setShort(const char* name, short value) throw (IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    string key = name ;
+    (*contentMap)[key] = MapItemHolder(value) ;
+}
+
+/*
+ * 
+ */
+p<string> ActiveMQMapMessage::getString(const char* name) throw (MessageFormatException, IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    PropertyMap::iterator tempIter ;
+    string key = name ;
+
+    // Check if key exists in map
+    tempIter = contentMap->find(key) ;
+    if( tempIter == contentMap->end() )
+        throw MessageFormatException("No short value available for given key") ;
+
+    try
+    {
+        // Try to get value as a string
+        return tempIter->second.getString() ;
+    }
+    catch( ConversionException ce )
+    {
+        throw MessageFormatException( ce.what() ) ;
+    }
+}
+
+/*
+ * 
+ */
+void ActiveMQMapMessage::setString(const char* name, p<string> value) throw (IllegalArgumentException)
+{
+    // Assert arguments
+    if( name == NULL || strcmp(name, "") == 0 )
+        throw IllegalArgumentException("Invalid key name") ;
+
+    string key = name ;
+    (*contentMap)[key] = MapItemHolder(value) ;
+}
+
+/*
+ * 
+ */
+array<string> ActiveMQMapMessage::getMapNames()
+{
+    PropertyMap::iterator tempIter ;
+    array<string> keyNames (contentMap->size()) ;
+    int        index = 0 ;
+
+    for( tempIter = contentMap->begin() ;
+         tempIter != contentMap->end() ;
+         tempIter++ )
+    {
+        keyNames[index++] = new string(tempIter->first) ;
+    }
+    return keyNames ;
+}
+
+/*
+ * 
+ */
+bool ActiveMQMapMessage::itemExists(const char* name)
+{
+    PropertyMap::iterator tempIter ;
+    string key = name ;
+
+    // Check if key exists in map
+    tempIter = contentMap->find(key) ;
+    return ( tempIter != contentMap->end() ) ? true : false ;
+}
+
+/*
+ *
+ */
+int ActiveMQMapMessage::marshal(p<IMarshaller> marshaller, int mode, p<IOutputStream> writer) throw (IOException)
+{
+    int size = 0 ;
+
+    // Update message content
+    if( mode == IMarshaller::MARSHAL_SIZE )
+    {
+        p<ByteArrayOutputStream> arrayWriter = new ByteArrayOutputStream() ;
+
+        // Marshal map into a byte array
+        marshaller->marshalMap(contentMap, mode, arrayWriter) ;
+
+        // Store map byte array in message content
+        this->content = arrayWriter->toArray() ;
+    }
+    // Note! Message content marshalling is done in super class
+    size += ActiveMQMessage::marshal(marshaller, mode, writer) ;
+
+    return size ;
+}
+
+/*
+ *
+ */
+void ActiveMQMapMessage::unmarshal(p<IMarshaller> marshaller, int mode, p<IInputStream> reader) throw (IOException)
+{
+    // Note! Message content unmarshalling is done in super class
+    ActiveMQMessage::unmarshal(marshaller, mode, reader) ;
+
+    // Extract map from message content
+    if( mode == IMarshaller::MARSHAL_READ )
+    {
+        p<ByteArrayInputStream> arrayReader = new ByteArrayInputStream( this->content ) ;
+
+        // Unmarshal map into a map
+        contentMap = marshaller->unmarshalMap(mode, arrayReader) ;
+    }
+}

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.hpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.hpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.hpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.hpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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.
+ */
+#ifndef ActiveMQ_ActiveMQMapMessage_hpp_
+#define ActiveMQ_ActiveMQMapMessage_hpp_
+
+// Turn off warning message for ignored exception specification
+#ifdef _MSC_VER
+#pragma warning( disable : 4290 )
+#endif
+
+#include <map>
+#include <string>
+#include "cms/IMapMessage.hpp"
+#include "cms/MessageFormatException.hpp"
+#include "activemq/command/ActiveMQMessage.hpp"
+#include "ppr/IllegalArgumentException.hpp"
+#include "ppr/io/IOutputStream.hpp"
+#include "ppr/io/IInputStream.hpp"
+#include "ppr/util/MapItemHolder.hpp"
+#include "ppr/util/ifr/array"
+#include "ppr/util/ifr/p"
+
+namespace apache
+{
+  namespace activemq
+  {
+    namespace command
+    {
+      using namespace ifr;
+      using namespace std;
+      using namespace apache::cms;
+      using namespace apache::ppr;
+      using namespace apache::ppr::io;
+      using namespace apache::ppr::util;
+
+/*
+ * 
+ */
+class ActiveMQMapMessage : public ActiveMQMessage, public IMapMessage
+{
+private:
+    p<string>      text ;
+    p<PropertyMap> contentMap ;
+
+public:
+    const static unsigned char TYPE = 25 ;
+
+public:
+    ActiveMQMapMessage() ;
+    virtual ~ActiveMQMapMessage() ;
+
+    virtual unsigned char getDataStructureType() ;
+
+    virtual p<PropertyMap> getBody() ;
+    virtual bool getBoolean(const char* name) throw (MessageFormatException, IllegalArgumentException) ;
+    virtual void setBoolean(const char* name, bool value) throw (IllegalArgumentException) ;
+    virtual char getByte(const char* name) throw (MessageFormatException, IllegalArgumentException) ;
+    virtual void setByte(const char* name, char value) throw (IllegalArgumentException) ;
+    virtual array<char> getBytes(const char* name) throw (MessageFormatException, IllegalArgumentException) ;
+    virtual void setBytes(const char* name, array<char> value) throw (IllegalArgumentException) ;
+    virtual double getDouble(const char* name) throw (MessageFormatException, IllegalArgumentException) ;
+    virtual void setDouble(const char* name, double value) throw (IllegalArgumentException) ;
+    virtual float getFloat(const char* name) throw (MessageFormatException, IllegalArgumentException) ;
+    virtual void setFloat(const char* name, float value) throw (IllegalArgumentException) ;
+    virtual int getInt(const char* name) throw (MessageFormatException, IllegalArgumentException) ;
+    virtual void setInt(const char* name, int value) throw (IllegalArgumentException) ;
+    virtual long long getLong(const char* name) throw (MessageFormatException, IllegalArgumentException) ;
+    virtual void setLong(const char* name, long long value) throw (IllegalArgumentException) ;
+    virtual short getShort(const char* name) throw (MessageFormatException, IllegalArgumentException) ;
+    virtual void setShort(const char* name, short value) throw (IllegalArgumentException) ;
+    virtual p<string> getString(const char* name) throw (MessageFormatException, IllegalArgumentException) ;
+    virtual void setString(const char* name, p<string> value) throw (IllegalArgumentException) ;
+    virtual array<string> getMapNames() ;
+    virtual bool itemExists(const char* name) ;
+
+    virtual int marshal(p<IMarshaller> marshaller, int mode, p<IOutputStream> writer) throw (IOException) ;
+    virtual void unmarshal(p<IMarshaller> marshaller, int mode, p<IInputStream> reader) throw (IOException) ;
+
+    //
+    // The methods below are needed to resolve the multiple
+    // inheritance of IMessage.
+    virtual void acknowledge() {
+        ActiveMQMessage::acknowledge() ;
+    } ;
+    virtual p<PropertyMap> getProperties() {
+        return ActiveMQMessage::getProperties() ;
+    } ;
+    virtual p<string> getJMSCorrelationID() {
+        return ActiveMQMessage::getJMSCorrelationID() ;
+    } ;
+    virtual void setJMSCorrelationID(const char* correlationId) {
+        return ActiveMQMessage::setJMSCorrelationID(correlationId) ;
+    } ;
+    virtual p<IDestination> getJMSDestination() {
+        return ActiveMQMessage::getJMSDestination() ;
+    } ;
+    virtual long long getJMSExpiration() {
+        return ActiveMQMessage::getJMSExpiration() ;
+    } ;
+    virtual void setJMSExpiration(long long time) {
+        return ActiveMQMessage::setJMSExpiration(time) ;
+    } ;
+    virtual p<string> getJMSMessageID() {
+        return ActiveMQMessage::getJMSMessageID() ;
+    } ;
+    virtual bool getJMSPersistent() {
+        return ActiveMQMessage::getJMSPersistent() ;
+    } ;
+    virtual void setJMSPersistent(bool persistent) {
+        return ActiveMQMessage::setJMSPersistent(persistent) ;
+    } ;
+    virtual unsigned char getJMSPriority() {
+        return ActiveMQMessage::getJMSPriority() ;
+    } ;
+    virtual void setJMSPriority(unsigned char priority) {
+        return ActiveMQMessage::setJMSPriority(priority) ;
+    } ;
+    virtual bool getJMSRedelivered() {
+        return ActiveMQMessage::getJMSRedelivered() ;
+    } ;
+    virtual p<IDestination> getJMSReplyTo() {
+        return ActiveMQMessage::getJMSReplyTo() ;
+    } ;
+    virtual void setJMSReplyTo(p<IDestination> destination) {
+        return ActiveMQMessage::setJMSReplyTo(destination) ;
+    } ;
+    virtual long long getJMSTimestamp() {
+        return ActiveMQMessage::getJMSTimestamp() ;
+    } ;
+    virtual p<string> getJMSType() {
+        return ActiveMQMessage::getJMSType() ;
+    } ;
+    virtual void setJMSType(const char* type) {
+        return ActiveMQMessage::setJMSType(type) ;
+    } ;
+    virtual int getJMSXDeliveryCount() {
+        return ActiveMQMessage::getJMSXDeliveryCount() ;
+    } ;
+    virtual p<string> getJMSXGroupID() {
+        return ActiveMQMessage::getJMSXGroupID() ;
+    } ;
+    virtual void setJMSXGroupID(const char* groupId) {
+        return ActiveMQMessage::setJMSXGroupID(groupId) ;
+    } ;
+    virtual int getJMSXGroupSeq() {
+        return ActiveMQMessage::getJMSXGroupSeq() ;
+    } ;
+    virtual void setJMSXGroupSeq(int sequence) {
+        return ActiveMQMessage::setJMSXGroupSeq(sequence) ;
+    } ;
+    virtual p<string> getJMSXProducerTxID() {
+        return ActiveMQMessage::getJMSXProducerTxID() ;
+    } ;
+} ;
+
+/* namespace */
+    }
+  }
+}
+
+#endif /*ActiveMQ_ActiveMQMapMessage_hpp_*/

Added: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMessage.cpp
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMessage.cpp?rev=397654&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMessage.cpp (added)
+++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMessage.cpp Thu Apr 27 14:59:28 2006
@@ -0,0 +1,374 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 "activemq/command/ActiveMQMessage.hpp"
+#include "ppr/io/ByteArrayOutputStream.hpp"
+#include "ppr/io/ByteArrayInputStream.hpp"
+
+using namespace apache::activemq::command;
+
+
+// Constructors -----------------------------------------------------
+
+
+// Attribute methods ------------------------------------------------
+
+/*
+ * 
+ */
+unsigned char ActiveMQMessage::getDataStructureType()
+{
+    return ActiveMQMessage::TYPE ;
+}
+
+/*
+ * 
+ */
+p<IDestination> ActiveMQMessage::getFromDestination()
+{
+    return this->destination ;
+}
+
+/*
+ * 
+ */
+void ActiveMQMessage::setFromDestination(p<IDestination> destination)
+{
+    this->destination = p_dyncast<ActiveMQDestination> (destination) ;
+}
+
+/*
+ * 
+ */
+void ActiveMQMessage::setAcknowledger(p<IAcknowledger> acknowledger) 
+{
+    this->acknowledger = acknowledger ;
+}
+
+/*
+ * 
+ */
+p<PropertyMap> ActiveMQMessage::getProperties()
+{
+    if( properties == NULL )
+        properties = new PropertyMap() ;
+
+    return properties;
+}
+
+/*
+ * 
+ */
+p<string> ActiveMQMessage::getJMSCorrelationID()
+{
+    return this->correlationId ;
+}
+
+/*
+ * 
+ */
+void ActiveMQMessage::setJMSCorrelationID(const char* correlationId)
+{
+    this->correlationId = new string(correlationId) ;
+}
+
+/*
+ * 
+ */
+p<IDestination> ActiveMQMessage::getJMSDestination()
+{
+    return this->originalDestination ;
+}
+
+/*
+ * 
+ */
+long long ActiveMQMessage::getJMSExpiration()
+{
+    return this->expiration ;
+}
+
+/*
+ * 
+ */
+void ActiveMQMessage::setJMSExpiration(long long time)
+{
+    this->expiration = time ;
+}
+
+/*
+ * 
+ */
+p<string> ActiveMQMessage::getJMSMessageID()
+{
+    p<string>     str ;
+    p<ProducerId> pid = this->getMessageId()->getProducerId() ;
+    char          buffer[256] ;
+
+    // Compose message id as a string
+#ifdef unix
+    sprintf(buffer, "%s:%lld:%lld:%lld", pid->getConnectionId()->c_str(),
+                                          pid->getSessionId(),
+                                          pid->getValue(),
+                                          messageId->getProducerSequenceId() ) ;
+#else
+    sprintf(buffer, "%s:%I64d:%I64d:%I64d", pid->getConnectionId()->c_str(),
+                                            pid->getSessionId(),
+                                            pid->getValue(),
+                                            messageId->getProducerSequenceId() ) ;
+#endif
+
+    str = new string(buffer) ;
+    return str ;
+}
+
+/*
+ * 
+ */
+bool ActiveMQMessage::getJMSPersistent()
+{
+    return this->persistent ;
+}
+
+/*
+ * 
+ */
+void ActiveMQMessage::setJMSPersistent(bool persistent)
+{
+    this->persistent = persistent ;
+}
+
+/*
+ * 
+ */
+unsigned char ActiveMQMessage::getJMSPriority()
+{
+    return this->priority ;
+}
+
+/*
+ * 
+ */
+void ActiveMQMessage::setJMSPriority(unsigned char priority)
+{
+    this->priority = priority ;
+}
+
+/*
+ * 
+ */
+bool ActiveMQMessage::getJMSRedelivered()
+{
+    return ( this->redeliveryCounter > 0 ) ? true : false ;
+}
+
+/*
+ * 
+ */
+p<IDestination> ActiveMQMessage::getJMSReplyTo()
+{
+    return this->replyTo ;
+}
+
+/*
+ * 
+ */
+void ActiveMQMessage::setJMSReplyTo(p<IDestination> destination)
+{
+    this->replyTo = p_dyncast<ActiveMQDestination> (destination) ;
+
+}
+
+/*
+ * 
+ */
+long long ActiveMQMessage::getJMSTimestamp()
+{
+    return this->timestamp ;
+}
+
+/*
+ * 
+ */
+p<string> ActiveMQMessage::getJMSType()
+{
+    return this->type ;
+}
+
+/*
+ * 
+ */
+void ActiveMQMessage::setJMSType(const char* type)
+{
+    this->type = new string(type) ;
+}
+
+/*
+ * 
+ */
+int ActiveMQMessage::getJMSXDeliveryCount()
+{
+    return this->redeliveryCounter + 1 ;
+}
+
+/*
+ * 
+ */
+p<string> ActiveMQMessage::getJMSXGroupID()
+{
+    return this->groupID ;
+}
+
+/*
+ * 
+ */
+void ActiveMQMessage::setJMSXGroupID(const char* groupId)
+{
+    this->groupID = new string(groupId) ;
+}
+
+/*
+ * 
+ */
+int ActiveMQMessage::getJMSXGroupSeq()
+{
+    return this->groupSequence ;
+}
+
+/*
+ * 
+ */
+void ActiveMQMessage::setJMSXGroupSeq(int sequence)
+{
+    this->groupSequence = sequence ;
+}
+
+/*
+ * 
+ */
+p<string> ActiveMQMessage::getJMSXProducerTxID()
+{
+    p<TransactionId> txId = this->originalTransactionId ;
+    p<string>        str ;
+    
+    if( txId == NULL )
+        txId = this->transactionId ;
+
+    if( txId != NULL )
+    {
+        if( txId->getDataStructureType() == LocalTransactionId::TYPE )
+        {
+            p<LocalTransactionId> localTxId = p_cast<LocalTransactionId> (txId) ;
+            char buffer[256] ;
+
+            // Compose local transaction id string
+#ifdef unix
+            sprintf(buffer, "%lld", localTxId->getValue() ) ;
+#else
+            sprintf(buffer, "%I64d", localTxId->getValue() ) ;
+#endif
+
+            str = new string(buffer ) ;
+            return str  ;
+        }
+        else if( txId->getDataStructureType() == XATransactionId::TYPE )
+        {
+            p<XATransactionId> xaTxId = p_cast<XATransactionId> (txId) ;
+            char buffer[256] ;
+
+            // Compose XA transaction id string
+            sprintf(buffer, "XID:%d:%s:%s", xaTxId->getFormatId(),
+                                            Hex::toString( xaTxId->getGlobalTransactionId() )->c_str(),
+                                            Hex::toString( xaTxId->getBranchQualifier() )->c_str() ) ;
+
+            str = new string(buffer ) ;
+            return str  ;
+        }
+        return NULL ;
+    }
+    return NULL ;
+}
+
+
+// Operation methods ------------------------------------------------
+
+/*
+ *
+ */
+void ActiveMQMessage::acknowledge()
+{
+    if( acknowledger != NULL )
+        acknowledger->acknowledge(smartify(this)) ;
+}
+
+
+// Implementation methods -------------------------------------------
+
+/*
+ * 
+ */
+int ActiveMQMessage::marshal(p<IMarshaller> marshaller, int mode, p<IOutputStream> writer) throw(IOException)
+{
+    int size = 0 ;
+
+    // Update message content if available
+    if( mode == IMarshaller::MARSHAL_SIZE && this->properties != NULL )
+    {
+        p<ByteArrayOutputStream> arrayWriter = new ByteArrayOutputStream() ;
+
+        // Marshal properties into a byte array
+        marshaller->marshalMap(properties, IMarshaller::MARSHAL_WRITE, arrayWriter) ;
+
+        // Store properties byte array in message content
+        this->marshalledProperties = arrayWriter->toArray() ;
+    }
+    // Note! Message propertys marshalling is done in super class
+    size += Message::marshal(marshaller, mode, writer) ;
+
+    return size ;
+}
+
+/*
+ * 
+ */
+void ActiveMQMessage::unmarshal(p<IMarshaller> marshaller, int mode, p<IInputStream> reader) throw(IOException)
+{
+    // Note! Message property unmarshalling is done in super class
+    Message::unmarshal(marshaller, mode, reader) ;
+
+    // Extract properties from message
+    if( mode == IMarshaller::MARSHAL_READ )
+    {
+        if( this->marshalledProperties != NULL )
+        {
+            p<ByteArrayInputStream> arrayReader = new ByteArrayInputStream( this->marshalledProperties ) ;
+
+            // Unmarshal map into a map
+            properties = marshaller->unmarshalMap(mode, arrayReader) ;
+        }
+    }
+}
+
+
+// Static methods ---------------------------------------------------
+
+/*
+ * 
+ */
+/*p<ActiveMQMessage> ActiveMQMessage::transform(p<IMessage> message)
+{
+    return p_cast<ActiveMQMessage> (message) ;
+}*/



Mime
View raw message