diff --git a/openwire-cpp/README.txt b/openwire-cpp/README.txt
new file mode 100644
index 0000000000..1c8635490f
--- /dev/null
+++ b/openwire-cpp/README.txt
@@ -0,0 +1,48 @@
+Apache ActiveMQ C++ Client
+==========================
+
+
+The ActiveMQ C++ client has support for both synchrounous and asynchrounous messaging as well as local transactions and more. To ease programming it uses smart pointers and STL extensively. For more information see included test programs.
+
+
+How to build
+============
+To run the supplied makefiles you need to set two environment variables, CONFIG and OSTYPE. With the help of variables the makefiles can determine what settings needs to be set for your platform.
+
+CONFIG can be set to either "debug" or "release" depending on what type of output you want. OSTYPE is set to "linux" or "macosx".
+
+For Windows, use the Visual Studio 2005 project files.
+
+
+Connection URI
+==============
+To connect to the ActiveMQ broker a URI is specified. The URI may have a set of configuration parameters that are used to configure the client.
+
+Sample URI: "tcp://192.168.64.142:61616?trace=false&protocol=openwire&encoding=none"
+
+Scheme
+------
+Name......: tcp
+Desciption: Type of transport protocol
+Mandatory.: Yes
+
+Parameters
+----------
+Name......: protocol
+Desciption: Type of wire protocol
+Default...: "openwire"
+Values....: "openwire"
+Mandatory.: No
+
+Name......: encoding
+Desciption: Character encoding
+Default...: "AsciiToUTF8"
+Values....: "none", "AsciiToUTF8"
+Mandatory.: No
+
+Name......: trace
+Desciption: Enables debug output to console
+Default...: "false"
+Values....: "true", "false"
+Mandatory.: No
+
diff --git a/openwire-cpp/activemq-cpp.vcproj b/openwire-cpp/activemq-cpp.vcproj
index 86e60b2920..43c95b2e03 100644
--- a/openwire-cpp/activemq-cpp.vcproj
+++ b/openwire-cpp/activemq-cpp.vcproj
@@ -46,6 +46,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)\amqlib.pdb"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
@@ -108,6 +109,7 @@
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)\amqlib.pdb"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
@@ -178,6 +180,14 @@
RelativePath=".\src\main\cpp\activemq\ConnectionClosedException.hpp"
>
+
+
+
+
@@ -198,6 +208,14 @@
RelativePath=".\src\main\cpp\activemq\ConsumerClosedException.hpp"
>
+
+
+
+
@@ -281,14 +299,6 @@
-
-
-
-
@@ -393,6 +403,14 @@
RelativePath=".\src\main\cpp\activemq\command\BaseCommand.hpp"
>
+
+
+
+
@@ -565,6 +583,14 @@
RelativePath=".\src\main\cpp\activemq\command\KeepAliveInfo.hpp"
>
+
+
+
+
@@ -613,6 +639,22 @@
RelativePath=".\src\main\cpp\activemq\command\MessageId.hpp"
>
+
+
+
+
+
+
+
+
@@ -645,6 +687,14 @@
RelativePath=".\src\main\cpp\activemq\command\RemoveSubscriptionInfo.hpp"
>
+
+
+
+
@@ -949,6 +999,22 @@
+
+
+
+
+
+
+
+
@@ -1013,6 +1079,30 @@
RelativePath=".\src\main\cpp\ppr\io\SocketOutputStream.hpp"
>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/openwire-cpp/makefile b/openwire-cpp/makefile
index 5cb92a1848..695bd6675e 100644
--- a/openwire-cpp/makefile
+++ b/openwire-cpp/makefile
@@ -1,5 +1,6 @@
SRCDIR = src/main/cpp
-MAKESUPPORT_HOME = $(PWD)
+TSTDIR = src/test/cpp
+MAKE_HOME = $(PWD)
LIBOFILES = \
$(OUTDIR)/activemq/BrokerException.o \
@@ -15,7 +16,6 @@ LIBOFILES = \
$(OUTDIR)/activemq/Session.o \
$(OUTDIR)/activemq/TransactionContext.o \
\
- $(OUTDIR)/activemq/command/AbstractCommand.o \
$(OUTDIR)/activemq/command/ActiveMQBytesMessage.o \
$(OUTDIR)/activemq/command/ActiveMQDestination.o \
$(OUTDIR)/activemq/command/ActiveMQMapMessage.o \
@@ -23,17 +23,21 @@ LIBOFILES = \
$(OUTDIR)/activemq/command/ActiveMQObjectMessage.o \
$(OUTDIR)/activemq/command/ActiveMQQueue.o \
$(OUTDIR)/activemq/command/ActiveMQStreamMessage.o \
+ $(OUTDIR)/activemq/command/ActiveMQTempDestination.o \
$(OUTDIR)/activemq/command/ActiveMQTempQueue.o \
$(OUTDIR)/activemq/command/ActiveMQTempTopic.o \
$(OUTDIR)/activemq/command/ActiveMQTextMessage.o \
$(OUTDIR)/activemq/command/ActiveMQTopic.o \
+ $(OUTDIR)/activemq/command/BaseDataStructure.o \
$(OUTDIR)/activemq/command/BaseCommand.o \
$(OUTDIR)/activemq/command/BrokerError.o \
$(OUTDIR)/activemq/command/BrokerId.o \
$(OUTDIR)/activemq/command/BrokerInfo.o \
+ $(OUTDIR)/activemq/command/ConnectionControl.o \
$(OUTDIR)/activemq/command/ConnectionError.o \
$(OUTDIR)/activemq/command/ConnectionId.o \
$(OUTDIR)/activemq/command/ConnectionInfo.o \
+ $(OUTDIR)/activemq/command/ConsumerControl.o \
$(OUTDIR)/activemq/command/ConsumerId.o \
$(OUTDIR)/activemq/command/ConsumerInfo.o \
$(OUTDIR)/activemq/command/ControlCommand.o \
@@ -49,16 +53,20 @@ LIBOFILES = \
$(OUTDIR)/activemq/command/JournalTrace.o \
$(OUTDIR)/activemq/command/JournalTransaction.o \
$(OUTDIR)/activemq/command/KeepAliveInfo.o \
+ $(OUTDIR)/activemq/command/LastPartialCommand.o \
$(OUTDIR)/activemq/command/LocalTransactionId.o \
$(OUTDIR)/activemq/command/Message.o \
$(OUTDIR)/activemq/command/MessageAck.o \
$(OUTDIR)/activemq/command/MessageDispatch.o \
$(OUTDIR)/activemq/command/MessageDispatchNotification.o \
$(OUTDIR)/activemq/command/MessageId.o \
+ $(OUTDIR)/activemq/command/NetworkBridgeFilter.o \
+ $(OUTDIR)/activemq/command/PartialCommand.o \
$(OUTDIR)/activemq/command/ProducerId.o \
$(OUTDIR)/activemq/command/ProducerInfo.o \
$(OUTDIR)/activemq/command/RemoveInfo.o \
$(OUTDIR)/activemq/command/RemoveSubscriptionInfo.o \
+ $(OUTDIR)/activemq/command/ReplayCommand.o \
$(OUTDIR)/activemq/command/Response.o \
$(OUTDIR)/activemq/command/SessionId.o \
$(OUTDIR)/activemq/command/SessionInfo.o \
@@ -68,7 +76,6 @@ LIBOFILES = \
$(OUTDIR)/activemq/command/TransactionInfo.o \
$(OUTDIR)/activemq/command/WireFormatInfo.o \
$(OUTDIR)/activemq/command/XATransactionId.o \
- $(OUTDIR)/activemq/command/ActiveMQTempDestination.o \
\
$(OUTDIR)/activemq/protocol/openwire/OpenWireMarshaller.o \
$(OUTDIR)/activemq/protocol/openwire/OpenWireProtocol.o \
@@ -84,6 +91,10 @@ LIBOFILES = \
\
$(OUTDIR)/cms/CmsException.o \
\
+ $(OUTDIR)/ppr/io/encoding/AsciiToUTF8Encoder.o \
+ $(OUTDIR)/ppr/io/encoding/CharsetEncoderRegistry.o \
+ $(OUTDIR)/ppr/io/BufferedInputStream.o \
+ $(OUTDIR)/ppr/io/BufferedOutputStream.o \
$(OUTDIR)/ppr/io/ByteArrayInputStream.o \
$(OUTDIR)/ppr/io/ByteArrayOutputStream.o \
$(OUTDIR)/ppr/io/DataInputStream.o \
@@ -106,12 +117,16 @@ LIBOFILES = \
OUTLIB = $(OUTDIR)/libactivemq.a
EXEOFILES = \
- $(OUTDIR)/TestMain.o \
- $(OUTDIR)/TestListener.o \
+ $(OUTDIR)/TestSuite.o \
+ $(OUTDIR)/TestSynchQueue.o \
+ $(OUTDIR)/TestAsynchQueue.o \
+ $(OUTDIR)/TestAsynchTopic.o \
+ $(OUTDIR)/TestLocalTXCommit.o \
EXELIBS = -lactivemq -lpthread -lstdc++
+OUTEXE = $(OUTDIR)/test
DEFINES =
-include $(MAKESUPPORT_HOME)/makefile.cfg
+include $(MAKE_HOME)/makefile.cfg
diff --git a/openwire-cpp/makefile-linux-debug.cfg b/openwire-cpp/makefile-linux-debug.cfg
index 048d0cab4b..b73317609a 100644
--- a/openwire-cpp/makefile-linux-debug.cfg
+++ b/openwire-cpp/makefile-linux-debug.cfg
@@ -9,6 +9,6 @@ CC = g++ -frtti -g -pthread -DDEBUG -D_DEBUG -D_REENTRANT
LD = g++ -g -frtti -pthread
CCFLAGS = -Wall
LDFLAGS = -luuid
-OUTDIR = $(MAKESUPPORT_HOME)/out
+OUTDIR = $(MAKE_HOME)/out
ARFLAGS =
diff --git a/openwire-cpp/makefile-linux-release.cfg b/openwire-cpp/makefile-linux-release.cfg
index 1e023583d4..9de460768e 100644
--- a/openwire-cpp/makefile-linux-release.cfg
+++ b/openwire-cpp/makefile-linux-release.cfg
@@ -9,7 +9,7 @@ CC = g++ -frtti -pthread -O3 -DNDEBUG -D_REENTRANT
LD = g++ -frtti -pthread
CCFLAGS = -Wall
LDFLAGS = -luuid
-OUTDIR = $(MAKESUPPORT_HOME)/out
+OUTDIR = $(MAKE_HOME)/out
ARFLAGS =
diff --git a/openwire-cpp/makefile-macosx-debug.cfg b/openwire-cpp/makefile-macosx-debug.cfg
index a1e22c9c9f..58aa5c384f 100644
--- a/openwire-cpp/makefile-macosx-debug.cfg
+++ b/openwire-cpp/makefile-macosx-debug.cfg
@@ -9,6 +9,6 @@ CC = g++ -frtti -g -DDEBUG -D_DEBUG -D_REENTRANT -DMACOSX -Dunix
LD = g++ -g -frtti
CCFLAGS = -Wall
LDFLAGS = -lpthread
-OUTDIR = $(MAKESUPPORT_HOME)/out
+OUTDIR = $(MAKE_HOME)/out
ARFLAGS =
diff --git a/openwire-cpp/makefile-macosx-release.cfg b/openwire-cpp/makefile-macosx-release.cfg
index d8fb00808c..64802d7c54 100644
--- a/openwire-cpp/makefile-macosx-release.cfg
+++ b/openwire-cpp/makefile-macosx-release.cfg
@@ -9,7 +9,7 @@ CC = g++ -frtti -O3 -DNDEBUG -D_REENTRANT -DMACOSX -Dunix
LD = g++ -frtti
CCFLAGS = -Wall
LDFLAGS = -lpthread
-OUTDIR = $(MAKESUPPORT_HOME)/out
+OUTDIR = $(MAKE_HOME)/out
ARFLAGS =
diff --git a/openwire-cpp/makefile.cfg b/openwire-cpp/makefile.cfg
index 0c9e4c2993..7ce86d722b 100644
--- a/openwire-cpp/makefile.cfg
+++ b/openwire-cpp/makefile.cfg
@@ -3,7 +3,7 @@ CURRENT = $(PWD)
# --- select compiler for structure
# ----------------------------------------------------------
-include $(MAKESUPPORT_HOME)/makefile-$(OSTYPE)-$(CONFIG).cfg
+include $(MAKE_HOME)/makefile-$(OSTYPE)-$(CONFIG).cfg
# --- set generic commmands
# ----------------------------------------------------------
@@ -46,6 +46,11 @@ $(OUTDIR)/%.o: $(SRCDIR)/%.cpp $(SRCDIR)/%.hpp
$(CC) -o $@ $(DEFINES) $(CCFLAGS) -I$(SRCDIR) \
$(LOCAL_INCLUDE) -c $<
+$(OUTDIR)/%.o: $(TSTDIR)/%.cpp $(TSTDIR)/%.hpp
+ $(ECHO) " - "$(CC) "'"$<"'"
+ $(CC) -o $@ $(DEFINES) $(CCFLAGS) -I$(SRCDIR) -I$(TSTDIR) \
+ $(LOCAL_INCLUDE) -c $<
+
# --- set generic targets and their handling procedures
# ----------------------------------------------------------
@@ -53,28 +58,32 @@ all: default
default: \
prepare \
- $(LIBOFILES) \
$(OUTLIB) \
postpare
+test: \
+ prepare \
+ $(OUTEXE) \
+ postpare
+
+
$(OUTLIB): $(LIBOFILES) $(DEPLIBS)
$(ECHO) " - Creating static library file "$@
$(AR) $(ARFLAGS) $@ $(LIBOFILES)
-test: $(OUTLIB)
- $(ECHO) " - Creating test executable"
- $(CC) $(CFLAGS) -I$(SRCDIR) -c $(SRCDIR)/../../test/cpp/TestMain.cpp $(OBJS) -o $(OUTDIR)/TestMain.o
- $(CC) $(CFLAGS) -I$(SRCDIR) -c $(SRCDIR)/../../test/cpp/TestListener.cpp $(OBJS) -o $(OUTDIR)/TestListener.o
- $(LD) $(LDFLAGS) -o $(OUTDIR)/$@ -L$(OUTDIR) $(EXEOFILES) $(EXELIBS)
+$(OUTEXE): $(OUTLIB) $(EXEOFILES)
+ $(ECHO) " - Creating test executable file "$(OUTEXE)
+ $(LD) $(LDFLAGS) -o $@ -L$(OUTDIR) $(EXEOFILES) $(EXELIBS)
clean:
$(ECHO) " - Cleaning up local directory "$(CURRENT)
$(ECHO) " - Removing object files"
$(RM) $(LIBOFILES)
+ $(RM) $(EXEOFILES)
$(ECHO) " - Removing file "$(OUTLIB)
$(RM) $(OUTLIB)
- $(ECHO) " - Removing file "$(TESTMAIN)
- $(RM) $(OUTDIR)/test
+ $(ECHO) " - Removing file "$(OUTEXE)
+ $(RM) $(OUTEXE)
$(RM) *~ *%
$(RM) #*
$(RM) core
@@ -93,6 +102,7 @@ prepare:
$(MD) $(OUTDIR)/cms; \
$(MD) $(OUTDIR)/ppr; \
$(MD) $(OUTDIR)/ppr/io; \
+ $(MD) $(OUTDIR)/ppr/io/encoding; \
$(MD) $(OUTDIR)/ppr/net; \
$(MD) $(OUTDIR)/ppr/thread; \
$(MD) $(OUTDIR)/ppr/util; \
diff --git a/openwire-cpp/src/gram/java/org/apache/activemq/openwire/tool/OpenWireCppClassesScript.java b/openwire-cpp/src/gram/java/org/apache/activemq/openwire/tool/OpenWireCppClassesScript.java
new file mode 100644
index 0000000000..d0dcffb4dd
--- /dev/null
+++ b/openwire-cpp/src/gram/java/org/apache/activemq/openwire/tool/OpenWireCppClassesScript.java
@@ -0,0 +1,209 @@
+/*
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.activemq.openwire.tool;
+
+import org.codehaus.jam.JClass;
+
+import java.io.File;
+
+/**
+ *
+ * @version $Revision: 379824 $
+ */
+public abstract class OpenWireCppClassesScript extends OpenWireClassesScript {
+
+ public Object run() {
+ filePostFix = getFilePostFix();
+ if (destDir == null) {
+ destDir = new File("../openwire-cpp/src/main/cpp/activemq/command");
+ }
+ return super.run();
+ }
+
+ protected String getFilePostFix() {
+ return ".cpp";
+ }
+
+ /**
+ * Converts the Java type to a C++ type name
+ */
+ public String toCppType(JClass type) {
+ String name = type.getSimpleName();
+ if (name.equals("String")) {
+ return "p";
+ }
+ else if (type.isArrayType()) {
+ if( name.equals("byte[]") )
+ name = "char[]" ;
+ else if( name.equals("DataStructure[]") )
+ name = "IDataStructure[]" ;
+
+ return "array<" + name.substring(0, name.length()-2) + ">";
+ }
+ else if (name.equals("Throwable") || name.equals("Exception")) {
+ return "p";
+ }
+ else if (name.equals("ByteSequence")) {
+ return "array";
+ }
+ else if (name.equals("boolean")) {
+ return "bool";
+ }
+ else if (name.equals("long")) {
+ return "long long";
+ }
+ else if (name.equals("byte")) {
+ return "char";
+ }
+ else if( name.equals("Command") || name.equals("DataStructure") ) {
+ return "p" ;
+ }
+ else if( !type.isPrimitiveType() ) {
+ return "p<" + name + ">" ;
+ }
+ else {
+ return name ;
+ }
+ }
+
+ /**
+ * Converts the Java type to a C++ default value
+ */
+ public String toCppDefaultValue(JClass type) {
+ String name = type.getSimpleName();
+
+ if ( name.equals("boolean") ) {
+ return "false";
+ }
+ else if (!type.isPrimitiveType()) {
+ return "NULL";
+ }
+ else {
+ return "0";
+ }
+ }
+
+ /**
+ * Converts the Java type to the name of the C++ marshal method
+ * to be used
+ */
+ public String toMarshalMethodName(JClass type) {
+ String name = type.getSimpleName();
+ if (name.equals("String")) {
+ return "marshalString";
+ }
+ else if (type.isArrayType()) {
+ if ( type.getArrayComponentType().isPrimitiveType() && name.equals("byte[]") )
+ return "marshalByteArray" ;
+ else
+ return "marshalObjectArray" ;
+ }
+ else if ( name.equals("ByteSequence") ) {
+ return "marshalByteArray";
+ }
+ else if (name.equals("short") ) {
+ return "marshalShort";
+ }
+ else if (name.equals("int") ) {
+ return "marshalInt";
+ }
+ else if (name.equals("long") ) {
+ return "marshalLong";
+ }
+ else if (name.equals("byte")) {
+ return "marshalByte";
+ }
+ else if (name.equals("double")) {
+ return "marshalDouble";
+ }
+ else if (name.equals("float")) {
+ return "marshalFloat";
+ }
+ else if (name.equals("boolean")) {
+ return "marshalBoolean";
+ }
+ else if( !type.isPrimitiveType() ) {
+ return "marshalObject" ;
+ }
+ else {
+ return name ;
+ }
+ }
+
+ /**
+ * Converts the Java type to the name of the C++ unmarshal method
+ * to be used
+ */
+ public String toUnmarshalMethodName(JClass type) {
+ String name = type.getSimpleName();
+ if (name.equals("String")) {
+ return "unmarshalString";
+ }
+ else if (type.isArrayType()) {
+ if ( type.getArrayComponentType().isPrimitiveType() && name.equals("byte[]") )
+ return "unmarshalByteArray" ;
+ else
+ return "unmarshalObjectArray" ;
+ }
+ else if ( name.equals("ByteSequence") ) {
+ return "unmarshalByteArray";
+ }
+ else if (name.equals("short") ) {
+ return "unmarshalShort";
+ }
+ else if (name.equals("int") ) {
+ return "unmarshalInt";
+ }
+ else if (name.equals("long") ) {
+ return "unmarshalLong";
+ }
+ else if (name.equals("byte")) {
+ return "unmarshalByte";
+ }
+ else if (name.equals("double")) {
+ return "unmarshalDouble";
+ }
+ else if (name.equals("float")) {
+ return "unmarshalFloat";
+ }
+ else if (name.equals("boolean")) {
+ return "unmarshalBoolean";
+ }
+ else if( !type.isPrimitiveType() ) {
+ return "unmarshalObject" ;
+ }
+ else {
+ return name ;
+ }
+ }
+
+ /**
+ * Converts the Java type to a C++ pointer cast
+ */
+ public String toUnmarshalCast(JClass type) {
+ String name = toCppType(type) ;
+
+ if( name.startsWith("p<") )
+ return "p_cast<" + name.substring(2) ;
+ else if( name.startsWith("array<") &&
+ (type.isArrayType() && !type.getArrayComponentType().isPrimitiveType()) &&
+ !type.getSimpleName().equals("ByteSequence") )
+ return "array_cast<" + name.substring(6) ;
+ else
+ return "" ;
+ }
+}
diff --git a/openwire-cpp/src/gram/java/org/apache/activemq/openwire/tool/OpenWireCppHeadersScript.java b/openwire-cpp/src/gram/java/org/apache/activemq/openwire/tool/OpenWireCppHeadersScript.java
new file mode 100644
index 0000000000..514e3114a4
--- /dev/null
+++ b/openwire-cpp/src/gram/java/org/apache/activemq/openwire/tool/OpenWireCppHeadersScript.java
@@ -0,0 +1,30 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.activemq.openwire.tool;
+
+
+/**
+ *
+ * @version $Revision: 379734 $
+ */
+public abstract class OpenWireCppHeadersScript extends OpenWireCppClassesScript {
+
+ protected String getFilePostFix() {
+ return ".hpp";
+ }
+
+}
diff --git a/openwire-cpp/src/gram/script/GenerateCppClasses.groovy b/openwire-cpp/src/gram/script/GenerateCppClasses.groovy
new file mode 100644
index 0000000000..05b2ed23a6
--- /dev/null
+++ b/openwire-cpp/src/gram/script/GenerateCppClasses.groovy
@@ -0,0 +1,125 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+import org.apache.activemq.openwire.tool.OpenWireCppClassesScript
+
+/**
+ * Generates the C++ commands for the Open Wire Format
+ *
+ * @version $Revision$
+ */
+class GenerateCppClasses extends OpenWireCppClassesScript {
+
+ void generateFile(PrintWriter out) {
+ out << """/*
+* 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/${className}.hpp"
+
+using namespace apache::activemq::command;
+
+/*
+ *
+ * Command and marshalling code for OpenWire format for ${className}
+ *
+ *
+ * NOTE!: This file is autogenerated - do not modify!
+ * if you need to make a change, please see the Groovy scripts in the
+ * activemq-core module
+ *
+ */
+${className}::${className}()
+{"""
+ for (property in properties) {
+ def value = toCppDefaultValue(property.type)
+ def propertyName = property.simpleName
+ def parameterName = decapitalize(propertyName)
+ out << """
+ this->${parameterName} = ${value} ;"""
+ }
+ out << """
+}
+
+${className}::~${className}()
+{
+}
+
+unsigned char ${className}::getDataStructureType()
+{
+ return ${className}::TYPE ;
+}
+"""
+ for (property in properties) {
+ def type = toCppType(property.type)
+ def propertyName = property.simpleName
+ def parameterName = decapitalize(propertyName)
+ out << """
+
+${type} ${className}::get${propertyName}()
+{
+ return ${parameterName} ;
+}
+
+void ${className}::set${propertyName}(${type} ${parameterName})
+{
+ this->${parameterName} = ${parameterName} ;
+}
+"""
+ }
+out << """
+int ${className}::marshal(p marshaller, int mode, p ostream) throw (IOException)
+{
+ int size = 0 ;
+
+ size += ${baseClass}::marshal(marshaller, mode, ostream) ; """
+ for (property in properties) {
+ def marshalMethod = toMarshalMethodName(property.type)
+ def propertyName = decapitalize(property.simpleName)
+ out << """
+ size += marshaller->${marshalMethod}(${propertyName}, mode, ostream) ; """
+ }
+out << """
+ return size ;
+}
+
+void ${className}::unmarshal(p marshaller, int mode, p istream) throw (IOException)
+{
+ ${baseClass}::unmarshal(marshaller, mode, istream) ; """
+ for (property in properties) {
+ def cast = toUnmarshalCast(property.type)
+ def unmarshalMethod = toUnmarshalMethodName(property.type)
+ def propertyName = decapitalize(property.simpleName)
+ out << """
+ ${propertyName} = ${cast}(marshaller->${unmarshalMethod}(mode, istream)) ; """
+ }
+out << """
+}
+"""
+ }
+}
diff --git a/openwire-cpp/src/gram/script/GenerateCppHeaders.groovy b/openwire-cpp/src/gram/script/GenerateCppHeaders.groovy
new file mode 100644
index 0000000000..4ddda0a028
--- /dev/null
+++ b/openwire-cpp/src/gram/script/GenerateCppHeaders.groovy
@@ -0,0 +1,153 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+import org.apache.activemq.openwire.tool.OpenWireCppHeadersScript
+
+/**
+ * Generates the C++ commands for the Open Wire Format
+ *
+ * @version $Revision$
+ */
+class GenerateCppHeaders extends OpenWireCppHeadersScript {
+
+ void generateFile(PrintWriter out) {
+ out << """/*
+* 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_${className}_hpp_
+#define ActiveMQ_${className}_hpp_
+
+// Turn off warning message for ignored exception specification
+#ifdef _MSC_VER
+#pragma warning( disable : 4290 )
+#endif
+
+#include
+"""
+ out << """#include "activemq/command/${baseClass}.hpp"
+"""
+for (property in properties)
+{
+ if( !property.type.isPrimitiveType() &&
+ property.type.simpleName != "String" &&
+ property.type.simpleName != "ByteSequence" )
+ {
+ def includeName = toCppType(property.type)
+ if( property.type.isArrayType() )
+ {
+ def arrayType = property.type.arrayComponentType ;
+ if( arrayType.isPrimitiveType() )
+ continue ;
+ }
+ if( includeName.startsWith("array<") )
+ includeName = includeName.substring(6, includeName.length()-1) ;
+ else if( includeName.startsWith("p<") )
+ includeName = includeName.substring(2, includeName.length()-1)
+
+ if( includeName.equals("IDataStructure") )
+ out << """#include "activemq/${includeName}.hpp"
+"""
+ else
+ out << """#include "activemq/command/${includeName}.hpp"
+"""
+ }
+}
+out << """
+#include "activemq/protocol/IMarshaller.hpp"
+#include "ppr/io/IOutputStream.hpp"
+#include "ppr/io/IInputStream.hpp"
+#include "ppr/io/IOException.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::activemq;
+ using namespace apache::activemq::protocol;
+ using namespace apache::ppr::io;
+
+/*
+ *
+ * Command and marshalling code for OpenWire format for ${className}
+ *
+ *
+ * NOTE!: This file is autogenerated - do not modify!
+ * if you need to make a change, please see the Groovy scripts in the
+ * activemq-core module
+ *
+ */
+class ${className} : public ${baseClass}
+{
+protected:
+"""
+ for (property in properties) {
+ def type = toCppType(property.type)
+ def name = decapitalize(property.simpleName)
+ out << """ $type $name ;
+"""
+ }
+ out << """
+public:
+ const static unsigned char TYPE = ${getOpenWireOpCode(jclass)};
+
+public:
+ ${className}() ;
+ virtual ~${className}() ;
+
+ virtual unsigned char getDataStructureType() ;
+"""
+ for (property in properties) {
+ def type = toCppType(property.type)
+ def propertyName = property.simpleName
+ def parameterName = decapitalize(propertyName)
+ out << """
+ virtual ${type} get${propertyName}() ;
+ virtual void set${propertyName}(${type} ${parameterName}) ;
+"""
+ }
+ out << """
+ virtual int marshal(p marshaller, int mode, p ostream) throw (IOException) ;
+ virtual void unmarshal(p marshaller, int mode, p istream) throw (IOException) ;
+} ;
+
+/* namespace */
+ }
+ }
+}
+
+#endif /*ActiveMQ_${className}_hpp_*/
+"""
+ }
+}
diff --git a/openwire-cpp/src/main/cpp/activemq/Connection.cpp b/openwire-cpp/src/main/cpp/activemq/Connection.cpp
index b12643b3d7..dec7437b56 100644
--- a/openwire-cpp/src/main/cpp/activemq/Connection.cpp
+++ b/openwire-cpp/src/main/cpp/activemq/Connection.cpp
@@ -206,7 +206,7 @@ p Connection::createSession(AcknowledgementMode ackMode) throw(CmsExce
/*
* Performs a synchronous request-response with the broker.
*/
-p Connection::syncRequest(p command) throw(CmsException)
+p Connection::syncRequest(p command) throw(CmsException)
{
checkConnected() ;
@@ -233,7 +233,7 @@ p Connection::syncRequest(p command) throw(CmsException)
/*
*
*/
-void Connection::oneway(p command) throw(CmsException)
+void Connection::oneway(p command) throw(CmsException)
{
checkConnected() ;
transport->oneway(command) ;
@@ -247,6 +247,35 @@ void Connection::disposeOf(p dataStructure) throw(CmsException)
p command = new RemoveInfo() ;
command->setObjectId( dataStructure ) ;
syncRequest(command) ;
+
+ //
+ // Delete session from internal list if a session id was supplied
+ // Note! Dispose of sessions should only be invoked from Session.close()
+ //
+ if( dataStructure->getDataStructureType() == SessionId::TYPE )
+ {
+ list< p >::iterator tempIter ;
+ p sessionId ;
+
+ // Convert data structure to a session id
+ sessionId = p_cast (dataStructure) ;
+
+ // Iterate through all sessions and check for a match on the session id
+ for( tempIter = sessions.begin() ;
+ tempIter != sessions.end() ;
+ tempIter++ )
+ {
+ p session = p_cast (*tempIter) ;
+
+ // Do we have a session id match?
+ if( session->getSessionId()->getValue() == sessionId->getValue() )
+ {
+ // Remove session
+ sessions.remove(session) ;
+ break ;
+ }
+ }
+ }
}
/*
@@ -332,7 +361,7 @@ void Connection::checkConnected() throw(CmsException)
/*
* Handle incoming commands.
*/
-void Connection::onCommand(p transport, p command)
+void Connection::onCommand(p transport, p command)
{
if( command->getDataStructureType() == MessageDispatch::TYPE )
{
diff --git a/openwire-cpp/src/main/cpp/activemq/Connection.hpp b/openwire-cpp/src/main/cpp/activemq/Connection.hpp
index 6fb48a0c39..a071145744 100644
--- a/openwire-cpp/src/main/cpp/activemq/Connection.hpp
+++ b/openwire-cpp/src/main/cpp/activemq/Connection.hpp
@@ -102,8 +102,8 @@ public:
// Operation methods
virtual p createSession() throw(CmsException) ;
virtual p createSession(AcknowledgementMode mode) throw(CmsException) ;
- virtual p syncRequest(p command) throw(CmsException) ;
- virtual void oneway(p command) throw(CmsException) ;
+ virtual p syncRequest(p command) throw(CmsException) ;
+ virtual void oneway(p command) throw(CmsException) ;
virtual void disposeOf(p dataStructure) throw(CmsException) ;
virtual p createTemporaryDestinationName() ;
virtual p createLocalTransactionId() ;
@@ -113,7 +113,7 @@ protected:
// Implementation methods
p createSessionInfo(AcknowledgementMode mode) ;
void checkConnected() throw(CmsException) ;
- void onCommand(p transport, p command) ;
+ void onCommand(p transport, p command) ;
void onError(p transport, exception& error) ;
} ;
diff --git a/openwire-cpp/src/main/cpp/activemq/ConnectionFactory.cpp b/openwire-cpp/src/main/cpp/activemq/ConnectionFactory.cpp
index 2ab50affa0..3249a399a9 100644
--- a/openwire-cpp/src/main/cpp/activemq/ConnectionFactory.cpp
+++ b/openwire-cpp/src/main/cpp/activemq/ConnectionFactory.cpp
@@ -27,7 +27,7 @@ using namespace apache::activemq;
ConnectionFactory::ConnectionFactory()
{
// Use default URI
- brokerUri = new Uri ("tcp://localhost:61616?wireFormat=openwire") ;
+ brokerUri = new Uri ("tcp://localhost:61616") ;
username = NULL ;
password = NULL ;
clientId = Guid::getGuidString() ;
diff --git a/openwire-cpp/src/main/cpp/activemq/ICommand.hpp b/openwire-cpp/src/main/cpp/activemq/ICommand.hpp
index cb22b02709..419a94986b 100644
--- a/openwire-cpp/src/main/cpp/activemq/ICommand.hpp
+++ b/openwire-cpp/src/main/cpp/activemq/ICommand.hpp
@@ -17,17 +17,18 @@
#ifndef ActiveMQ_ICommand_hpp_
#define ActiveMQ_ICommand_hpp_
-#include "activemq/IDataStructure.hpp"
+#include "ppr/util/ifr/p"
namespace apache
{
namespace activemq
{
+ using namespace ifr;
/*
* An OpenWire command
*/
-struct ICommand : IDataStructure
+struct ICommand : Interface
{
virtual int getCommandId() = 0;
virtual void setCommandId(int value) = 0;
diff --git a/openwire-cpp/src/main/cpp/activemq/IDataStructure.hpp b/openwire-cpp/src/main/cpp/activemq/IDataStructure.hpp
index 3a0bd29597..16bc8fd82b 100644
--- a/openwire-cpp/src/main/cpp/activemq/IDataStructure.hpp
+++ b/openwire-cpp/src/main/cpp/activemq/IDataStructure.hpp
@@ -39,7 +39,6 @@ namespace apache
struct IDataStructure : Interface
{
virtual unsigned char getDataStructureType() = 0 ;
- virtual bool isMarshallAware() = 0 ;
virtual int marshal(p marshaller, int mode, p writer) = 0 ;
virtual void unmarshal(p marshaller, int mode, p reader) = 0 ;
} ;
diff --git a/openwire-cpp/src/main/cpp/activemq/MessageConsumer.cpp b/openwire-cpp/src/main/cpp/activemq/MessageConsumer.cpp
index 50310ae4d3..a0e5e07512 100644
--- a/openwire-cpp/src/main/cpp/activemq/MessageConsumer.cpp
+++ b/openwire-cpp/src/main/cpp/activemq/MessageConsumer.cpp
@@ -162,10 +162,11 @@ void MessageConsumer::dispatchAsyncMessages()
if( message != NULL )
{
- listener->onMessage(message) ;
-
// Auto acknowledge message if selected
autoAcknowledge(message) ;
+
+ // Let listener process message
+ listener->onMessage(message) ;
}
else
break ;
diff --git a/openwire-cpp/src/main/cpp/activemq/Session.cpp b/openwire-cpp/src/main/cpp/activemq/Session.cpp
index 8cd6153d67..a301637071 100644
--- a/openwire-cpp/src/main/cpp/activemq/Session.cpp
+++ b/openwire-cpp/src/main/cpp/activemq/Session.cpp
@@ -421,6 +421,11 @@ void Session::close()
map >::iterator consumerIter ;
map >::iterator producerIter ;
+ // Shutdown dispatch thread
+ dispatchThread->interrupt() ;
+ dispatchThread->join() ;
+ dispatchThread = NULL ;
+
// Iterate through all consumers and close them down
for( consumerIter = consumers.begin() ;
consumerIter != consumers.end() ;
@@ -438,12 +443,13 @@ void Session::close()
producerIter->second->close() ;
producerIter->second = NULL ;
}
- // De-register session from broker
+ // De-register session from broker/connection
connection->disposeOf( sessionInfo->getSessionId() ) ;
// Clean up
connection = NULL ;
closed = true ;
+
}
}
diff --git a/openwire-cpp/src/main/cpp/activemq/Session.hpp b/openwire-cpp/src/main/cpp/activemq/Session.hpp
index f6e3832a7e..a731ef4974 100644
--- a/openwire-cpp/src/main/cpp/activemq/Session.hpp
+++ b/openwire-cpp/src/main/cpp/activemq/Session.hpp
@@ -134,6 +134,7 @@ public:
void interrupt()
{
interrupted = true ;
+ wakeup() ;
}
void wakeup()
@@ -144,13 +145,19 @@ public:
protected:
virtual void run () throw (p)
{
- while( !interrupted )
+ do
{
// Wait for wake-up call
semaphore.wait() ;
+ if( interrupted )
+ break ;
+
session->dispatchAsyncMessages() ;
- }
+ } while( !interrupted ) ;
+
+ // Clean up (prevent cyclic dependency)
+ session = NULL ;
}
} ;
diff --git a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.cpp b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.cpp
index 567ea21a49..0d77c78b2d 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.cpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.cpp
@@ -24,8 +24,10 @@ using namespace apache::activemq::command;
*/
ActiveMQBytesMessage::ActiveMQBytesMessage()
{
- this->in = NULL ;
- this->out = new ByteArrayOutputStream() ;
+ this->bis = NULL ;
+ this->bos = new ByteArrayOutputStream() ;
+ this->dis = NULL ;
+ this->dos = new DataOutputStream( bos ) ;
this->readMode = false ;
}
@@ -38,8 +40,10 @@ ActiveMQBytesMessage::ActiveMQBytesMessage(char* body, int size)
array buffer = array (size) ;
memcpy(buffer.c_array(), body, size);
- this->in = NULL ;
- this->out = new ByteArrayOutputStream(buffer) ;
+ this->bis = NULL ;
+ this->bos = new ByteArrayOutputStream(buffer) ;
+ this->dis = NULL ;
+ this->dos = new DataOutputStream( bos ) ;
this->readMode = false ;
}
@@ -63,10 +67,20 @@ unsigned char ActiveMQBytesMessage::getDataStructureType()
*/
void ActiveMQBytesMessage::reset()
{
- if( !readMode )
+ if( readMode )
{
- this->in = new ByteArrayInputStream( out->toArray() ) ;
- this->out = NULL ;
+ this->bos = new ByteArrayOutputStream( bis->toArray() ) ;
+ this->bis = NULL ;
+ this->dos = new DataOutputStream( bos ) ;
+ this->dis = NULL ;
+ this->readMode = false ;
+ }
+ else
+ {
+ this->bis = new ByteArrayInputStream( bos->toArray() ) ;
+ this->bos = NULL ;
+ this->dis = new DataInputStream( bis ) ;
+ this->dos = NULL ;
this->readMode = true ;
}
}
@@ -83,7 +97,7 @@ char ActiveMQBytesMessage::readByte() throw(MessageNotReadableException, Message
try
{
// Read a single byte
- return readByte() ;
+ return dis->readByte() ;
}
catch( EOFException eof )
{
@@ -94,7 +108,7 @@ char ActiveMQBytesMessage::readByte() throw(MessageNotReadableException, Message
/*
*
*/
-int ActiveMQBytesMessage::readBytes(char* buffer, int index, int length) throw (MessageNotReadableException, MessageEOFException)
+int ActiveMQBytesMessage::readBytes(char* buffer, int offset, int length) throw (MessageNotReadableException, MessageEOFException)
{
// Assert read mode
if( !readMode )
@@ -103,7 +117,7 @@ int ActiveMQBytesMessage::readBytes(char* buffer, int index, int length) throw (
try
{
// Read some bytes
- return in->read(buffer, index, length) ;
+ return dis->read(buffer, offset, length) ;
}
catch( EOFException eof )
{
@@ -123,7 +137,7 @@ bool ActiveMQBytesMessage::readBoolean() throw(MessageNotReadableException, Mess
try
{
// Read a boolean
- return in->readBoolean() ;
+ return dis->readBoolean() ;
}
catch( EOFException eof )
{
@@ -143,7 +157,7 @@ double ActiveMQBytesMessage::readDouble() throw(MessageNotReadableException, Mes
try
{
// Read a double
- return in->readDouble() ;
+ return dis->readDouble() ;
}
catch( EOFException eof )
{
@@ -163,7 +177,7 @@ float ActiveMQBytesMessage::readFloat() throw(MessageNotReadableException, Messa
try
{
// Read a float
- return in->readFloat() ;
+ return dis->readFloat() ;
}
catch( EOFException eof )
{
@@ -183,7 +197,7 @@ short ActiveMQBytesMessage::readShort() throw(MessageNotReadableException, Messa
try
{
// Read a short
- return in->readShort() ;
+ return dis->readShort() ;
}
catch( EOFException eof )
{
@@ -203,7 +217,7 @@ int ActiveMQBytesMessage::readInt() throw(MessageNotReadableException, MessageEO
try
{
// Read an integer
- return in->readInt() ;
+ return dis->readInt() ;
}
catch( EOFException eof )
{
@@ -223,7 +237,7 @@ long long ActiveMQBytesMessage::readLong() throw(MessageNotReadableException, Me
try
{
// Read a long long
- return in->readLong() ;
+ return dis->readLong() ;
}
catch( EOFException eof )
{
@@ -234,7 +248,7 @@ long long ActiveMQBytesMessage::readLong() throw(MessageNotReadableException, Me
/*
*
*/
-p ActiveMQBytesMessage::readUTF() throw(MessageNotReadableException, MessageEOFException)
+p ActiveMQBytesMessage::readString() throw(MessageNotReadableException, MessageEOFException)
{
// Assert read mode
if( !readMode )
@@ -243,7 +257,7 @@ p ActiveMQBytesMessage::readUTF() throw(MessageNotReadableException, Mes
try
{
// Read a string
- return in->readString() ;
+ return dis->readString() ;
}
catch( EOFException eof )
{
@@ -261,20 +275,20 @@ void ActiveMQBytesMessage::writeByte(char value) throw (MessageNotWritableExcept
throw MessageNotWritableException() ;
// Write a single byte
- out->writeByte(value) ;
+ dos->writeByte(value) ;
}
/*
*
*/
-void ActiveMQBytesMessage::writeBytes(char* value, int index, int length) throw (MessageNotWritableException)
+void ActiveMQBytesMessage::writeBytes(char* value, int offset, int length) throw (MessageNotWritableException)
{
// Assert write mode
if( readMode )
throw MessageNotWritableException() ;
// Write some bytes
- out->write(value, index, length) ;
+ dos->write(value, offset, length) ;
}
/*
@@ -287,7 +301,7 @@ void ActiveMQBytesMessage::writeBoolean(bool value) throw (MessageNotWritableExc
throw MessageNotWritableException() ;
// Write a boolean
- out->writeBoolean(value) ;
+ dos->writeBoolean(value) ;
}
/*
@@ -300,7 +314,7 @@ void ActiveMQBytesMessage::writeDouble(double value) throw (MessageNotWritableEx
throw MessageNotWritableException() ;
// Write a double
- out->writeDouble(value) ;
+ dos->writeDouble(value) ;
}
/*
@@ -313,7 +327,7 @@ void ActiveMQBytesMessage::writeFloat(float value) throw (MessageNotWritableExce
throw MessageNotWritableException() ;
// Write a float
- out->writeFloat(value) ;
+ dos->writeFloat(value) ;
}
/*
@@ -326,7 +340,7 @@ void ActiveMQBytesMessage::writeInt(int value) throw (MessageNotWritableExceptio
throw MessageNotWritableException() ;
// Write an integer
- out->writeInt(value) ;
+ dos->writeInt(value) ;
}
/*
@@ -339,7 +353,7 @@ void ActiveMQBytesMessage::writeLong(long long value) throw (MessageNotWritableE
throw MessageNotWritableException() ;
// Write a long long
- out->writeLong(value) ;
+ dos->writeLong(value) ;
}
/*
@@ -352,13 +366,13 @@ void ActiveMQBytesMessage::writeShort(short value) throw (MessageNotWritableExce
throw MessageNotWritableException() ;
// Write a short
- out->writeShort(value) ;
+ dos->writeShort(value) ;
}
/*
*
*/
-void ActiveMQBytesMessage::writeUTF(const char* value) throw (MessageNotWritableException)
+void ActiveMQBytesMessage::writeString(const char* value) throw (MessageNotWritableException)
{
// Assert write mode
if( readMode )
@@ -366,22 +380,22 @@ void ActiveMQBytesMessage::writeUTF(const char* value) throw (MessageNotWritable
// Write a string
p v = new string(value) ;
- out->writeString(v) ;
+ dos->writeString(v) ;
}
/*
*
*/
-int ActiveMQBytesMessage::marshal(p marshaller, int mode, p writer) throw (IOException)
+int ActiveMQBytesMessage::marshal(p marshaller, int mode, p ostream) throw (IOException)
{
int size = 0 ;
// Copy body to message content container
if( mode == IMarshaller::MARSHAL_SIZE )
- this->content = ( readMode) ? in->toArray() : out->toArray() ;
+ this->content = ( readMode) ? bis->toArray() : bos->toArray() ;
// size += (int)this->content.size() ;
- size += ActiveMQMessage::marshal(marshaller, mode, writer) ;
+ size += ActiveMQMessage::marshal(marshaller, mode, ostream) ;
// Note! Message content marshalling is done in super class
@@ -391,16 +405,18 @@ int ActiveMQBytesMessage::marshal(p marshaller, int mode, p marshaller, int mode, p reader) throw (IOException)
+void ActiveMQBytesMessage::unmarshal(p marshaller, int mode, p istream) throw (IOException)
{
// Note! Message content unmarshalling is done in super class
- ActiveMQMessage::unmarshal(marshaller, mode, reader) ;
+ ActiveMQMessage::unmarshal(marshaller, mode, istream) ;
// Copy body to message content holder
if( mode == IMarshaller::MARSHAL_READ )
{
- in = new ByteArrayInputStream( this->content ) ;
- out = NULL ;
+ bis = new ByteArrayInputStream( this->content ) ;
+ bos = NULL ;
+ dis = new DataInputStream( bis ) ;
+ dos = NULL ;
readMode = true ;
}
}
diff --git a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.hpp b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.hpp
index fcd8385a19..d151e821c8 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.hpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.hpp
@@ -30,6 +30,8 @@
#include "activemq/command/ActiveMQMessage.hpp"
#include "ppr/io/ByteArrayInputStream.hpp"
#include "ppr/io/ByteArrayOutputStream.hpp"
+#include "ppr/io/DataInputStream.hpp"
+#include "ppr/io/DataOutputStream.hpp"
#include "ppr/io/EOFException.hpp"
#include "ppr/util/Endian.hpp"
#include "ppr/util/MapItemHolder.hpp"
@@ -53,9 +55,11 @@ namespace apache
class ActiveMQBytesMessage : public ActiveMQMessage , public IBytesMessage
{
private:
- p in ;
- p out ;
- bool readMode ;
+ p dis ;
+ p dos ;
+ p bis ;
+ p bos ;
+ bool readMode ;
const static int INITIAL_SIZE = 256 ;
const static int EXPAND_SIZE = 128 ;
@@ -72,23 +76,23 @@ public:
virtual void reset() ;
virtual char readByte() throw (MessageNotReadableException, MessageEOFException) ;
- virtual int readBytes(char* buffer, int index, int length) throw (MessageNotReadableException, MessageEOFException) ;
+ virtual int readBytes(char* buffer, int offset, 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 readUTF() throw (MessageNotReadableException, MessageEOFException) ;
+ virtual p readString() 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 writeBytes(char* value, int offset, 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 void writeString(const char* value) throw (MessageNotWritableException) ;
virtual int marshal(p marshaller, int mode, p writer) throw (IOException) ;
virtual void unmarshal(p marshaller, int mode, p reader) throw (IOException) ;
diff --git a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.cpp b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.cpp
index b9291709c2..c75a47e227 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.cpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.cpp
@@ -347,18 +347,18 @@ p ActiveMQDestination::getClientId(p destination)
/*
*
*/
-int ActiveMQDestination::marshal(p marshaller, int mode, p writer) throw (IOException)
+int ActiveMQDestination::marshal(p marshaller, int mode, p ostream) throw (IOException)
{
int size = 0 ;
- size += marshaller->marshalString(physicalName, mode, writer) ;
+ size += marshaller->marshalString(physicalName, mode, ostream) ;
return size ;
}
/*
*
*/
-void ActiveMQDestination::unmarshal(p marshaller, int mode, p reader) throw (IOException)
+void ActiveMQDestination::unmarshal(p marshaller, int mode, p istream) throw (IOException)
{
- physicalName = p_cast(marshaller->unmarshalString(mode, reader)) ;
+ physicalName = p_cast(marshaller->unmarshalString(mode, istream)) ;
}
diff --git a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.hpp b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.hpp
index 1ac368a87b..07c3c880ca 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.hpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.hpp
@@ -23,7 +23,7 @@
#include "cms/IQueue.hpp"
#include "cms/ITemporaryTopic.hpp"
#include "cms/ITemporaryQueue.hpp"
-#include "activemq/command/AbstractCommand.hpp"
+#include "activemq/command/BaseCommand.hpp"
#include "activemq/protocol/IMarshaller.hpp"
#include "ppr/io/IOutputStream.hpp"
#include "ppr/io/IInputStream.hpp"
@@ -49,7 +49,7 @@ namespace apache
/*
*
*/
-class ActiveMQDestination : public AbstractCommand, public IDestination
+class ActiveMQDestination : public BaseCommand, public IDestination
{
private:
p orderedTarget,
@@ -109,8 +109,8 @@ public:
virtual bool isWildcard() ;
virtual p toString() ;
- virtual int marshal(p marshaller, int mode, p writer) throw (IOException) ;
- virtual void unmarshal(p marshaller, int mode, p reader) throw (IOException) ;
+ virtual int marshal(p marshaller, int mode, p ostream) throw (IOException) ;
+ virtual void unmarshal(p marshaller, int mode, p istream) throw (IOException) ;
//
// Abstract methods
diff --git a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.cpp b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.cpp
index c02609d62b..3c34c57cf9 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.cpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.cpp
@@ -15,8 +15,11 @@
* limitations under the License.
*/
#include "activemq/command/ActiveMQMapMessage.hpp"
+
#include "ppr/io/ByteArrayOutputStream.hpp"
#include "ppr/io/ByteArrayInputStream.hpp"
+#include "ppr/io/DataOutputStream.hpp"
+#include "ppr/io/DataInputStream.hpp"
using namespace apache::activemq::command;
@@ -411,7 +414,7 @@ p ActiveMQMapMessage::getString(const char* name) throw (MessageFormatEx
/*
*
*/
-void ActiveMQMapMessage::setString(const char* name, p value) throw (IllegalArgumentException)
+void ActiveMQMapMessage::setString(const char* name, const char* value) throw (IllegalArgumentException)
{
// Assert arguments
if( name == NULL || strcmp(name, "") == 0 )
@@ -455,23 +458,24 @@ bool ActiveMQMapMessage::itemExists(const char* name)
/*
*
*/
-int ActiveMQMapMessage::marshal(p marshaller, int mode, p writer) throw (IOException)
+int ActiveMQMapMessage::marshal(p marshaller, int mode, p ostream) throw (IOException)
{
int size = 0 ;
- // Update message content
+ // Update message content during size lookup
if( mode == IMarshaller::MARSHAL_SIZE )
{
- p arrayWriter = new ByteArrayOutputStream() ;
+ p bos = new ByteArrayOutputStream() ;
+ p dos = new DataOutputStream( bos ) ;
// Marshal map into a byte array
- marshaller->marshalMap(contentMap, mode, arrayWriter) ;
+ marshaller->marshalMap(contentMap, IMarshaller::MARSHAL_WRITE, dos) ;
// Store map byte array in message content
- this->content = arrayWriter->toArray() ;
+ this->content = bos->toArray() ;
}
// Note! Message content marshalling is done in super class
- size += ActiveMQMessage::marshal(marshaller, mode, writer) ;
+ size += ActiveMQMessage::marshal(marshaller, mode, ostream) ;
return size ;
}
@@ -479,17 +483,18 @@ int ActiveMQMapMessage::marshal(p marshaller, int mode, p marshaller, int mode, p reader) throw (IOException)
+void ActiveMQMapMessage::unmarshal(p marshaller, int mode, p istream) throw (IOException)
{
// Note! Message content unmarshalling is done in super class
- ActiveMQMessage::unmarshal(marshaller, mode, reader) ;
+ ActiveMQMessage::unmarshal(marshaller, mode, istream) ;
// Extract map from message content
if( mode == IMarshaller::MARSHAL_READ )
{
- p arrayReader = new ByteArrayInputStream( this->content ) ;
+ p bis = new ByteArrayInputStream( this->content ) ;
+ p dis = new DataInputStream( bis ) ;
// Unmarshal map into a map
- contentMap = marshaller->unmarshalMap(mode, arrayReader) ;
+ contentMap = marshaller->unmarshalMap(mode, dis) ;
}
}
diff --git a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.hpp b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.hpp
index 0d58f8123f..8f65859c6d 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.hpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.hpp
@@ -83,12 +83,12 @@ public:
virtual short getShort(const char* name) throw (MessageFormatException, IllegalArgumentException) ;
virtual void setShort(const char* name, short value) throw (IllegalArgumentException) ;
virtual p getString(const char* name) throw (MessageFormatException, IllegalArgumentException) ;
- virtual void setString(const char* name, p value) throw (IllegalArgumentException) ;
+ virtual void setString(const char* name, const char* value) throw (IllegalArgumentException) ;
virtual array getMapNames() ;
virtual bool itemExists(const char* name) ;
- virtual int marshal(p marshaller, int mode, p writer) throw (IOException) ;
- virtual void unmarshal(p marshaller, int mode, p reader) throw (IOException) ;
+ virtual int marshal(p marshaller, int mode, p ostream) throw (IOException) ;
+ virtual void unmarshal(p marshaller, int mode, p istream) throw (IOException) ;
//
// The methods below are needed to resolve the multiple
diff --git a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMessage.cpp b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMessage.cpp
index f264951368..32222923d3 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMessage.cpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMessage.cpp
@@ -15,8 +15,11 @@
* limitations under the License.
*/
#include "activemq/command/ActiveMQMessage.hpp"
+
#include "ppr/io/ByteArrayOutputStream.hpp"
#include "ppr/io/ByteArrayInputStream.hpp"
+#include "ppr/io/DataOutputStream.hpp"
+#include "ppr/io/DataInputStream.hpp"
using namespace apache::activemq::command;
@@ -320,23 +323,24 @@ void ActiveMQMessage::acknowledge()
/*
*
*/
-int ActiveMQMessage::marshal(p marshaller, int mode, p writer) throw(IOException)
+int ActiveMQMessage::marshal(p marshaller, int mode, p ostream) throw(IOException)
{
int size = 0 ;
// Update message content if available
if( mode == IMarshaller::MARSHAL_SIZE && this->properties != NULL )
{
- p arrayWriter = new ByteArrayOutputStream() ;
+ p bos = new ByteArrayOutputStream() ;
+ p dos = new DataOutputStream( bos ) ;
// Marshal properties into a byte array
- marshaller->marshalMap(properties, IMarshaller::MARSHAL_WRITE, arrayWriter) ;
+ marshaller->marshalMap(properties, IMarshaller::MARSHAL_WRITE, dos) ;
// Store properties byte array in message content
- this->marshalledProperties = arrayWriter->toArray() ;
+ this->marshalledProperties = bos->toArray() ;
}
// Note! Message propertys marshalling is done in super class
- size += Message::marshal(marshaller, mode, writer) ;
+ size += Message::marshal(marshaller, mode, ostream) ;
return size ;
}
@@ -344,31 +348,21 @@ int ActiveMQMessage::marshal(p marshaller, int mode, p marshaller, int mode, p reader) throw(IOException)
+void ActiveMQMessage::unmarshal(p marshaller, int mode, p istream) throw(IOException)
{
// Note! Message property unmarshalling is done in super class
- Message::unmarshal(marshaller, mode, reader) ;
+ Message::unmarshal(marshaller, mode, istream) ;
// Extract properties from message
if( mode == IMarshaller::MARSHAL_READ )
{
if( this->marshalledProperties != NULL )
{
- p arrayReader = new ByteArrayInputStream( this->marshalledProperties ) ;
+ p bis = new ByteArrayInputStream( this->marshalledProperties ) ;
+ p dis = new DataInputStream( bis ) ;
// Unmarshal map into a map
- properties = marshaller->unmarshalMap(mode, arrayReader) ;
+ properties = marshaller->unmarshalMap(mode, dis) ;
}
}
}
-
-
-// Static methods ---------------------------------------------------
-
-/*
- *
- */
-/*p ActiveMQMessage::transform(p message)
-{
- return p_cast (message) ;
-}*/
diff --git a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMessage.hpp b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMessage.hpp
index 4d8ec2e220..cdf3cc2a5a 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMessage.hpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMessage.hpp
@@ -88,12 +88,8 @@ public:
protected:
// Implementation
- int marshal(p marshaller, int mode, p writer) throw(IOException) ;
- void unmarshal(p marshaller, int mode, p reader) throw(IOException) ;
-
-public:
- // Static methods
- //static p transform(p message) ;
+ int marshal(p marshaller, int mode, p ostream) throw(IOException) ;
+ void unmarshal(p marshaller, int mode, p istream) throw(IOException) ;
} ;
/* namespace */
diff --git a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQTextMessage.cpp b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQTextMessage.cpp
index 394a5c727d..75c4bac901 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQTextMessage.cpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQTextMessage.cpp
@@ -23,6 +23,7 @@ using namespace apache::activemq::command;
*/
ActiveMQTextMessage::ActiveMQTextMessage()
{
+ encoder = CharsetEncoderRegistry::getEncoder() ;
setText(NULL) ;
}
@@ -31,6 +32,16 @@ ActiveMQTextMessage::ActiveMQTextMessage()
*/
ActiveMQTextMessage::ActiveMQTextMessage(const char* text)
{
+ encoder = CharsetEncoderRegistry::getEncoder() ;
+ setText(text) ;
+}
+
+/*
+ *
+ */
+ActiveMQTextMessage::ActiveMQTextMessage(const char* text, const char* encname)
+{
+ encoder = CharsetEncoderRegistry::getEncoder(encname) ;
setText(text) ;
}
@@ -57,17 +68,16 @@ p ActiveMQTextMessage::getText()
// Extract text from message content
if( this->content.size() > 0 )
{
- int utflen = 0 ;
- char* buffer = this->content.c_array() ;
+ p value ;
- // TODO: assuming that the text is ASCII
- utflen |= (char) ((buffer[0] << 24) & 0xFF) ;
- utflen |= (char) ((buffer[1] >> 16) & 0xFF);
- utflen |= (char) ((buffer[2] >> 8) & 0xFF);
- utflen |= (char) ((buffer[3] >> 0) & 0xFF);
+ // Use undecoded string, skip string length
+ value = new string( this->content.c_array() + sizeof(int), this->content.size() - sizeof(int) ) ;
- p text = new string( buffer + 4, this->content.size() - 4 ) ;
- return text ;
+ // Decode string if an encoder has been set up
+ if( encoder != NULL )
+ value = encoder->decode( value ) ;
+
+ return value ;
}
return NULL ;
}
@@ -79,19 +89,32 @@ void ActiveMQTextMessage::setText(const char* text)
{
if( text != NULL )
{
- int length = (int)strlen(text) ;
- int utflen = length ;
+ p dos ;
+ p bos ;
+ p value ;
+ int length ;
- // TODO: assuming that the text is ASCII
- this->content = array (length + 4) ;
+ // Set up in-memory streams
+ bos = new ByteArrayOutputStream() ;
+ dos = new DataOutputStream( bos ) ;
- this->content[0] = (char) ((utflen >> 24) & 0xFF) ;
- this->content[1] = (char) ((utflen >> 16) & 0xFF);
- this->content[2] = (char) ((utflen >> 8) & 0xFF);
- this->content[3] = (char) ((utflen >> 0) & 0xFF);
+ // Encode string if an encoder has been set up
+ if( encoder != NULL )
+ {
+ // Encode string
+ value = encoder->encode( p (new string(text)), &length) ;
+ }
+ else // ...use unencoded string
+ {
+ length = (int)strlen(text) ;
+ value = new string(text) ;
+ }
+ // Prepend data with the string length (4 bytes)
+ dos->writeInt( length ) ;
+ dos->write( value->c_str(), 0, length ) ;
- for( int i = 0 ; i < length ; i++ )
- this->content[4+i] = text[i] ;
+ // Finally, store text in content holder
+ this->content = bos->toArray() ;
}
else
this->content = NULL ;
diff --git a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQTextMessage.hpp b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQTextMessage.hpp
index 73cc281307..1f53f84d5c 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/ActiveMQTextMessage.hpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/ActiveMQTextMessage.hpp
@@ -20,6 +20,10 @@
#include
#include "cms/ITextMessage.hpp"
#include "activemq/command/ActiveMQMessage.hpp"
+#include "ppr/io/ByteArrayOutputStream.hpp"
+#include "ppr/io/DataOutputStream.hpp"
+#include "ppr/io/encoding/ICharsetEncoder.hpp"
+#include "ppr/io/encoding/CharsetEncoderRegistry.hpp"
#include "ppr/util/MapItemHolder.hpp"
#include "ppr/util/ifr/p"
@@ -31,6 +35,8 @@ namespace apache
{
using namespace ifr;
using namespace apache::cms;
+ using namespace apache::ppr::io;
+ using namespace apache::ppr::io::encoding;
using namespace apache::ppr::util;
/*
@@ -38,12 +44,16 @@ namespace apache
*/
class ActiveMQTextMessage : public ActiveMQMessage, public ITextMessage
{
+private:
+ p encoder ;
+
public:
const static unsigned char TYPE = 28 ;
public:
ActiveMQTextMessage() ;
ActiveMQTextMessage(const char* text) ;
+ ActiveMQTextMessage(const char* text, const char* encname) ;
virtual ~ActiveMQTextMessage() ;
virtual unsigned char getDataStructureType() ;
diff --git a/openwire-cpp/src/main/cpp/activemq/command/BaseCommand.cpp b/openwire-cpp/src/main/cpp/activemq/command/BaseCommand.cpp
index 5c6dd10426..17a592b3b2 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/BaseCommand.cpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/BaseCommand.cpp
@@ -21,17 +21,77 @@ using namespace apache::activemq::command;
// Attribute methods ------------------------------------------------
+/*
+ *
+ */
+int BaseCommand::getCommandId()
+{
+ return commandId ;
+}
+
+/*
+ *
+ */
+void BaseCommand::setCommandId(int id)
+{
+ commandId = id ;
+}
+
+/*
+ *
+ */
+bool BaseCommand::getResponseRequired()
+{
+ return responseRequired ;
+}
+
+/*
+ *
+ */
+void BaseCommand::setResponseRequired(bool value)
+{
+ responseRequired = value ;
+}
+
+/*
+ *
+ */
int BaseCommand::getHashCode()
{
- return ( commandId * 38 ) + getDataStructureType() ;
+ return ( commandId * 38 ) + BaseDataStructure::getDataStructureType() ;
}
// Operation methods ------------------------------------------------
+/*
+ *
+ */
+int BaseCommand::marshal(p marshaller, int mode, p ostream) throw(IOException)
+{
+ int size = 0 ;
+
+ size += marshaller->marshalInt(commandId, mode, ostream) ;
+ size += marshaller->marshalBoolean(responseRequired, mode, ostream) ;
+
+ return size ;
+}
+
+/*
+ *
+ */
+void BaseCommand::unmarshal(p marshaller, int mode, p istream) throw(IOException)
+{
+ commandId = marshaller->unmarshalInt(mode, istream) ;
+ responseRequired = marshaller->unmarshalBoolean(mode, istream) ;
+}
+
+/*
+ *
+ */
bool BaseCommand::operator== (BaseCommand& that)
{
- if( this->getDataStructureType() == that.getDataStructureType() &&
+ if( BaseDataStructure::getDataStructureType() == ((BaseDataStructure)that).getDataStructureType() &&
this->commandId == that.commandId )
{
return true ;
@@ -39,12 +99,15 @@ bool BaseCommand::operator== (BaseCommand& that)
return false ;
}
+/*
+ *
+ */
p BaseCommand::toString()
{
p str = new string() ;
char buffer[10] ;
- str->assign( getDataStructureTypeAsString( getDataStructureType() )->c_str() ) ;
+ str->assign( BaseDataStructure::getDataStructureTypeAsString( BaseDataStructure::getDataStructureType() )->c_str() ) ;
if( str->length() == 0 )
str->assign("") ;
diff --git a/openwire-cpp/src/main/cpp/activemq/command/BaseCommand.hpp b/openwire-cpp/src/main/cpp/activemq/command/BaseCommand.hpp
index 99144a7597..4eb1c1c449 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/BaseCommand.hpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/BaseCommand.hpp
@@ -18,7 +18,12 @@
#define ActiveMQ_BaseCommand_hpp_
#include
-#include "activemq/command/AbstractCommand.hpp"
+#include "activemq/ICommand.hpp"
+#include "activemq/command/BaseDataStructure.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
@@ -29,13 +34,28 @@ namespace apache
{
using namespace ifr;
using namespace std;
+ using namespace apache::activemq;
+ using namespace apache::activemq::protocol;
+ using namespace apache::ppr::io;
/*
*
*/
-class BaseCommand : public AbstractCommand
+class BaseCommand : public BaseDataStructure, public ICommand
{
+protected:
+ int commandId ;
+ bool responseRequired ;
+
public:
+ virtual int getCommandId() ;
+ virtual void setCommandId(int id) ;
+ virtual bool getResponseRequired() ;
+ virtual void setResponseRequired(bool value) ;
+
+ virtual int marshal(p marshaller, int mode, p ostream) throw(IOException) ;
+ virtual void unmarshal(p marshaller, int mode, p istream) throw(IOException) ;
+
// Equals operator
bool operator== (BaseCommand& other) ;
diff --git a/openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.cpp b/openwire-cpp/src/main/cpp/activemq/command/BaseDataStructure.cpp
similarity index 80%
rename from openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.cpp
rename to openwire-cpp/src/main/cpp/activemq/command/BaseDataStructure.cpp
index 6a442a4b12..2f4c91ca46 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.cpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/BaseDataStructure.cpp
@@ -15,7 +15,8 @@
* limitations under the License.
*/
#include
-#include "activemq/command/AbstractCommand.hpp"
+#include "activemq/command/BaseDataStructure.hpp"
+
#include "activemq/command/ActiveMQMessage.hpp"
#include "activemq/command/ActiveMQBytesMessage.hpp"
#include "activemq/command/ActiveMQMapMessage.hpp"
@@ -23,6 +24,11 @@
#include "activemq/command/ActiveMQStreamMessage.hpp"
#include "activemq/command/ActiveMQTextMessage.hpp"
#include "activemq/command/ActiveMQQueue.hpp"
+#include "activemq/command/ActiveMQTopic.hpp"
+#include "activemq/command/ActiveMQTempQueue.hpp"
+#include "activemq/command/ActiveMQTempTopic.hpp"
+#include "activemq/command/ExceptionResponse.hpp"
+#include "activemq/command/ConnectionId.hpp"
#include "activemq/command/ConsumerId.hpp"
#include "activemq/command/ProducerId.hpp"
#include "activemq/command/MessageId.hpp"
@@ -49,39 +55,7 @@ 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()
+unsigned char BaseDataStructure::getDataStructureType()
{
return 0 ;
}
@@ -89,15 +63,7 @@ unsigned char AbstractCommand::getDataStructureType()
/*
*
*/
-bool AbstractCommand::isMarshallAware()
-{
- return false ;
-}
-
-/*
- *
- */
-int AbstractCommand::marshal(p marshaller, int mode, p writer) throw(IOException)
+int BaseDataStructure::marshal(p marshaller, int mode, p ostream) throw(IOException)
{
return 0 ;
}
@@ -105,15 +71,15 @@ int AbstractCommand::marshal(p marshaller, int mode, p marshaller, int mode, p reader) throw(IOException)
+void BaseDataStructure::unmarshal(p marshaller, int mode, p istream) throw(IOException)
{
}
/*
*
*/
-p AbstractCommand::createObject(unsigned char type)
- {
+p BaseDataStructure::createObject(unsigned char type)
+{
switch( type )
{
case ActiveMQMessage::TYPE:
@@ -130,6 +96,16 @@ p AbstractCommand::createObject(unsigned char type)
return new ActiveMQMapMessage() ;
case ActiveMQQueue::TYPE:
return new ActiveMQQueue() ;
+ case ActiveMQTopic::TYPE:
+ return new ActiveMQTopic() ;
+ case ActiveMQTempQueue::TYPE:
+ return new ActiveMQTempQueue() ;
+ case ActiveMQTempTopic::TYPE:
+ return new ActiveMQTempTopic() ;
+ case ExceptionResponse::TYPE:
+ return new ExceptionResponse() ;
+ case ConnectionId::TYPE:
+ return new ConnectionId() ;
case ConsumerId::TYPE:
return new ConsumerId() ;
case ProducerId::TYPE:
@@ -178,7 +154,7 @@ p AbstractCommand::createObject(unsigned char type)
/*
*
*/
-p AbstractCommand::getDataStructureTypeAsString(unsigned char type)
+p BaseDataStructure::getDataStructureTypeAsString(unsigned char type)
{
p packetType = new string() ;
@@ -205,6 +181,12 @@ p AbstractCommand::getDataStructureTypeAsString(unsigned char type)
case ActiveMQQueue::TYPE:
packetType->assign("ACTIVEMQ_QUEUE") ;
break ;
+ case ActiveMQTopic::TYPE:
+ packetType->assign("ACTIVEMQ_TOPIC") ;
+ break ;
+ case ConnectionId::TYPE:
+ packetType->assign("CONNECTION_ID") ;
+ break ;
case ConsumerId::TYPE:
packetType->assign("CONSUMER_ID") ;
break ;
@@ -226,6 +208,9 @@ p AbstractCommand::getDataStructureTypeAsString(unsigned char type)
case Response::TYPE:
packetType->assign("RESPONSE") ;
break ;
+ case ExceptionResponse::TYPE:
+ packetType->assign("EXCEPTION_RESPONSE") ;
+ break ;
case ConsumerInfo::TYPE:
packetType->assign("CONSUMER_INFO") ;
break ;
diff --git a/openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.hpp b/openwire-cpp/src/main/cpp/activemq/command/BaseDataStructure.hpp
similarity index 67%
rename from openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.hpp
rename to openwire-cpp/src/main/cpp/activemq/command/BaseDataStructure.hpp
index 8d28b92d92..b44c57357f 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/AbstractCommand.hpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/BaseDataStructure.hpp
@@ -14,11 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef ActiveMQ_AbstractCommand_hpp_
-#define ActiveMQ_AbstractCommand_hpp_
+#ifndef ActiveMQ_BaseDataStructure_hpp_
+#define ActiveMQ_BaseDataStructure_hpp_
#include
-#include "activemq/ICommand.hpp"
#include "activemq/IDataStructure.hpp"
#include "ppr/io/IOutputStream.hpp"
#include "ppr/io/IInputStream.hpp"
@@ -39,24 +38,16 @@ namespace apache
/*
*
*/
-class AbstractCommand : public ICommand
+class BaseDataStructure : public IDataStructure
{
protected:
- int commandId ;
- bool responseRequired ;
+ BaseDataStructure() { } ;
-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 marshaller, int mode, p writer) throw(IOException) ;
- virtual void unmarshal(p marshaller, int mode, p reader) throw(IOException) ;
+ virtual int marshal(p marshaller, int mode, p ostream) throw(IOException) ;
+ virtual void unmarshal(p marshaller, int mode, p istream) throw(IOException) ;
static p createObject(unsigned char type) ;
static p getDataStructureTypeAsString(unsigned char type) ;
@@ -67,4 +58,4 @@ public:
}
}
-#endif /*ActiveMQ_AbstractCommand_hpp_*/
+#endif /*ActiveMQ_BaseDataStructure_hpp_*/
diff --git a/openwire-cpp/src/main/cpp/activemq/command/BrokerError.hpp b/openwire-cpp/src/main/cpp/activemq/command/BrokerError.hpp
index 3a7d8fae8e..b3444252ff 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/BrokerError.hpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/BrokerError.hpp
@@ -20,7 +20,7 @@
#include
#include
#include
-#include "activemq/command/AbstractCommand.hpp"
+#include "activemq/command/BaseCommand.hpp"
#include "ppr/util/ifr/array"
#include "ppr/util/ifr/p"
@@ -47,7 +47,7 @@ struct StackTraceElement
/*
* Represents an exception on the broker.
*/
-class BrokerError : public AbstractCommand
+class BrokerError : public BaseCommand
{
private:
p message ;
diff --git a/openwire-cpp/src/main/cpp/activemq/command/BrokerId.cpp b/openwire-cpp/src/main/cpp/activemq/command/BrokerId.cpp
index 3610f84e00..f56dbcefb3 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/BrokerId.cpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/BrokerId.cpp
@@ -1,67 +1,69 @@
-/*
-* 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/BrokerId.hpp"
-
-using namespace apache::activemq::command;
-
-/*
- *
- * Marshalling code for Open Wire Format for BrokerId
- *
- *
- * NOTE!: This file is autogenerated - do not modify!
- * if you need to make a change, please see the Groovy scripts in the
- * activemq-core module
- *
- */
-BrokerId::BrokerId()
-{
- this->value = NULL ;
-}
-
-BrokerId::~BrokerId()
-{
-}
-
-unsigned char BrokerId::getDataStructureType()
-{
- return BrokerId::TYPE ;
-}
-
-
-p BrokerId::getValue()
-{
- return value ;
-}
-
-void BrokerId::setValue(p value)
-{
- this->value = value ;
-}
-
-int BrokerId::marshal(p marshaller, int mode, p writer) throw (IOException)
-{
- int size = 0 ;
-
- size += marshaller->marshalString(value, mode, writer) ;
- return size ;
-}
-
-void BrokerId::unmarshal(p marshaller, int mode, p reader) throw (IOException)
-{
- value = p_cast(marshaller->unmarshalString(mode, reader)) ;
-}
+/*
+* 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/BrokerId.hpp"
+
+using namespace apache::activemq::command;
+
+/*
+ *
+ * Command and marshalling code for OpenWire format for BrokerId
+ *
+ *
+ * NOTE!: This file is autogenerated - do not modify!
+ * if you need to make a change, please see the Groovy scripts in the
+ * activemq-core module
+ *
+ */
+BrokerId::BrokerId()
+{
+ this->value = NULL ;
+}
+
+BrokerId::~BrokerId()
+{
+}
+
+unsigned char BrokerId::getDataStructureType()
+{
+ return BrokerId::TYPE ;
+}
+
+
+p BrokerId::getValue()
+{
+ return value ;
+}
+
+void BrokerId::setValue(p value)
+{
+ this->value = value ;
+}
+
+int BrokerId::marshal(p marshaller, int mode, p ostream) throw (IOException)
+{
+ int size = 0 ;
+
+ size += BaseDataStructure::marshal(marshaller, mode, ostream) ;
+ size += marshaller->marshalString(value, mode, ostream) ;
+ return size ;
+}
+
+void BrokerId::unmarshal(p marshaller, int mode, p istream) throw (IOException)
+{
+ BaseDataStructure::unmarshal(marshaller, mode, istream) ;
+ value = p_cast(marshaller->unmarshalString(mode, istream)) ;
+}
diff --git a/openwire-cpp/src/main/cpp/activemq/command/BrokerId.hpp b/openwire-cpp/src/main/cpp/activemq/command/BrokerId.hpp
index 3cb6f1437d..4d8511aad4 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/BrokerId.hpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/BrokerId.hpp
@@ -1,82 +1,83 @@
-/*
-* 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_BrokerId_hpp_
-#define ActiveMQ_BrokerId_hpp_
-
-// Turn off warning message for ignored exception specification
-#ifdef _MSC_VER
-#pragma warning( disable : 4290 )
-#endif
-
-#include
-#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/array"
-#include "ppr/util/ifr/p"
-
-namespace apache
-{
- namespace activemq
- {
- namespace command
- {
- using namespace ifr;
- using namespace std;
- using namespace apache::activemq;
- using namespace apache::activemq::protocol;
- using namespace apache::ppr::io;
-
-/*
- *
- * Marshalling code for Open Wire Format for BrokerId
- *
- *
- * NOTE!: This file is autogenerated - do not modify!
- * if you need to make a change, please see the Groovy scripts in the
- * activemq-core module
- *
- */
-class BrokerId : public AbstractCommand
-{
-protected:
- p value ;
-
-public:
- const static unsigned char TYPE = 124;
-
-public:
- BrokerId() ;
- virtual ~BrokerId() ;
-
- virtual unsigned char getDataStructureType() ;
-
- virtual p getValue() ;
- virtual void setValue(p value) ;
-
- virtual int marshal(p marshaller, int mode, p writer) throw (IOException) ;
- virtual void unmarshal(p marshaller, int mode, p reader) throw (IOException) ;
-} ;
-
-/* namespace */
- }
- }
-}
-
-#endif /*ActiveMQ_BrokerId_hpp_*/
+/*
+* 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_BrokerId_hpp_
+#define ActiveMQ_BrokerId_hpp_
+
+// Turn off warning message for ignored exception specification
+#ifdef _MSC_VER
+#pragma warning( disable : 4290 )
+#endif
+
+#include
+#include "activemq/command/BaseDataStructure.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/array"
+#include "ppr/util/ifr/p"
+
+namespace apache
+{
+ namespace activemq
+ {
+ namespace command
+ {
+ using namespace ifr;
+ using namespace std;
+ using namespace apache::activemq;
+ using namespace apache::activemq::protocol;
+ using namespace apache::ppr::io;
+
+/*
+ *
+ * Command and marshalling code for OpenWire format for BrokerId
+ *
+ *
+ * NOTE!: This file is autogenerated - do not modify!
+ * if you need to make a change, please see the Groovy scripts in the
+ * activemq-core module
+ *
+ */
+class BrokerId : public BaseDataStructure
+{
+protected:
+ p value ;
+
+public:
+ const static unsigned char TYPE = 124;
+
+public:
+ BrokerId() ;
+ virtual ~BrokerId() ;
+
+ virtual unsigned char getDataStructureType() ;
+
+ virtual p getValue() ;
+ virtual void setValue(p value) ;
+
+ virtual int marshal(p marshaller, int mode, p ostream) throw (IOException) ;
+ virtual void unmarshal(p marshaller, int mode, p istream) throw (IOException) ;
+} ;
+
+/* namespace */
+ }
+ }
+}
+
+#endif /*ActiveMQ_BrokerId_hpp_*/
diff --git a/openwire-cpp/src/main/cpp/activemq/command/BrokerInfo.cpp b/openwire-cpp/src/main/cpp/activemq/command/BrokerInfo.cpp
index 11631a6ae1..0a3c5da948 100644
--- a/openwire-cpp/src/main/cpp/activemq/command/BrokerInfo.cpp
+++ b/openwire-cpp/src/main/cpp/activemq/command/BrokerInfo.cpp
@@ -1,127 +1,153 @@
-/*
-* 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/BrokerInfo.hpp"
-
-using namespace apache::activemq::command;
-
-/*
- *
- * Marshalling code for Open Wire Format for BrokerInfo
- *
- *
- * NOTE!: This file is autogenerated - do not modify!
- * if you need to make a change, please see the Groovy scripts in the
- * activemq-core module
- *
- */
-BrokerInfo::BrokerInfo()
-{
- this->brokerId = NULL ;
- this->brokerURL = NULL ;
- this->peerBrokerInfos = NULL ;
- this->brokerName = NULL ;
- this->slaveBroker = false ;
-}
-
-BrokerInfo::~BrokerInfo()
-{
-}
-
-unsigned char BrokerInfo::getDataStructureType()
-{
- return BrokerInfo::TYPE ;
-}
-
-
-p BrokerInfo::getBrokerId()
-{
- return brokerId ;
-}
-
-void BrokerInfo::setBrokerId(p brokerId)
-{
- this->brokerId = brokerId ;
-}
-
-
-p BrokerInfo::getBrokerURL()
-{
- return brokerURL ;
-}
-
-void BrokerInfo::setBrokerURL(p brokerURL)
-{
- this->brokerURL = brokerURL ;
-}
-
-
-array