activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [30/51] [partial] https://issues.apache.org/jira/browse/OPENWIRE-1
Date Thu, 24 Jul 2014 14:23:19 GMT
http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-interop-tests/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/openwire-interop-tests/src/test/resources/log4j.properties b/openwire-interop-tests/src/test/resources/log4j.properties
new file mode 100644
index 0000000..0588275
--- /dev/null
+++ b/openwire-interop-tests/src/test/resources/log4j.properties
@@ -0,0 +1,41 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You 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.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, out, stdout
+
+log4j.logger.org.apache.activemq.openwire=DEBUG
+
+# Tune the ActiveMQ and it's OpenWire transport as needed for debugging.
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.broker=DEBUG
+log4j.logger.org.apache.activemq.transport.openwire=TRACE
+log4j.logger.org.apache.activemq.transport.openwire.FRAMES=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/activemq-test.log
+log4j.appender.out.append=true

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-jms/.gitignore
----------------------------------------------------------------------
diff --git a/openwire-jms/.gitignore b/openwire-jms/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/openwire-jms/.gitignore
@@ -0,0 +1 @@
+/target

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-jms/pom.xml
----------------------------------------------------------------------
diff --git a/openwire-jms/pom.xml b/openwire-jms/pom.xml
new file mode 100644
index 0000000..a68d4a4
--- /dev/null
+++ b/openwire-jms/pom.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.activemq</groupId>
+    <artifactId>openwire-protocol</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>openwire-jms</artifactId>
+  <name>openwire-jms</name>
+  <description>OpenWire JMS Message mappings allowing for easier implementation of a JMS client using OpenWire</description>
+  <packaging>jar</packaging>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <!-- =================================== -->
+    <!-- Required Dependencies                -->
+    <!-- =================================== -->
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>openwire-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-jms_1.1_spec</artifactId>
+    </dependency>
+
+    <!-- =================================== -->
+    <!-- Testing Dependencies                -->
+    <!-- =================================== -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>activemq-broker</artifactId>
+      <version>${activemq-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>activemq-kahadb-store</artifactId>
+      <version>${activemq-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>activemq-jaas</artifactId>
+      <version>${activemq-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>activemq-spring</artifactId>
+      <version>${activemq-version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSBytesMessage.java
----------------------------------------------------------------------
diff --git a/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSBytesMessage.java b/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSBytesMessage.java
new file mode 100644
index 0000000..8ce1c1a
--- /dev/null
+++ b/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSBytesMessage.java
@@ -0,0 +1,783 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jms;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.MessageEOFException;
+import javax.jms.MessageFormatException;
+import javax.jms.MessageNotReadableException;
+import javax.jms.MessageNotWriteableException;
+
+import org.apache.activemq.openwire.commands.OpenWireBytesMessage;
+import org.apache.activemq.openwire.utils.ExceptionSupport;
+import org.fusesource.hawtbuf.Buffer;
+import org.fusesource.hawtbuf.ByteArrayInputStream;
+import org.fusesource.hawtbuf.ByteArrayOutputStream;
+
+/**
+ * Wrapper class that provides ByteMessage compliant mappings to the OpenWireBytesMessage
+ */
+public class OpenWireJMSBytesMessage extends OpenWireJMSMessage implements BytesMessage {
+
+    private final OpenWireBytesMessage message;
+
+    protected transient DataOutputStream dataOut;
+    protected transient ByteArrayOutputStream bytesOut;
+    protected transient DataInputStream dataIn;
+    protected transient int length;
+
+    /**
+     * Creates a new instance that wraps a new OpenWireJMSBytesMessage instance.
+     */
+    public OpenWireJMSBytesMessage() {
+        this(new OpenWireBytesMessage());
+    }
+
+    /**
+     * Creates a new instance that wraps the given OpenWireJMSBytesMessage
+     *
+     * @param message
+     *        the OpenWireMessage to wrap.
+     */
+    public OpenWireJMSBytesMessage(OpenWireBytesMessage message) {
+        super(message);
+        this.message = message;
+    }
+
+    @Override
+    public OpenWireJMSBytesMessage copy() throws JMSException {
+        storeContent();
+        OpenWireJMSBytesMessage other = new OpenWireJMSBytesMessage(message.copy());
+        other.copy(this);
+        return other;
+    }
+
+    private void copy(OpenWireJMSBytesMessage other) throws JMSException {
+        super.copy(other);
+        bytesOut = null;
+        dataIn = null;
+    }
+
+    @Override
+    public void clearBody() throws JMSException {
+        super.clearBody();
+        message.clearBody();
+        dataOut = null;
+        dataIn = null;
+        bytesOut = null;
+    }
+
+    @Override
+    public long getBodyLength() throws JMSException {
+        return message.getBodyLength();
+    }
+
+    /**
+     * Reads a <code>boolean</code> from the bytes message stream.
+     *
+     * @return the <code>boolean</code> value read
+     * @throws JMSException if the JMS provider fails to read the message due to
+     *                 some internal error.
+     * @throws MessageEOFException if unexpected end of bytes stream has been
+     *                 reached.
+     * @throws MessageNotReadableException if the message is in write-only mode.
+     */
+    @Override
+    public boolean readBoolean() throws JMSException {
+        initializeReading();
+        try {
+            return this.dataIn.readBoolean();
+        } catch (EOFException e) {
+            throw ExceptionSupport.createMessageEOFException(e);
+        } catch (IOException e) {
+            throw ExceptionSupport.createMessageFormatException(e);
+        }
+    }
+
+    /**
+     * Reads a signed 8-bit value from the bytes message stream.
+     *
+     * @return the next byte from the bytes message stream as a signed 8-bit
+     *         <code>byte</code>
+     * @throws JMSException if the JMS provider fails to read the message due to
+     *                 some internal error.
+     * @throws MessageEOFException if unexpected end of bytes stream has been
+     *                 reached.
+     * @throws MessageNotReadableException if the message is in write-only mode.
+     */
+    @Override
+    public byte readByte() throws JMSException {
+        initializeReading();
+        try {
+            return this.dataIn.readByte();
+        } catch (EOFException e) {
+            throw ExceptionSupport.createMessageEOFException(e);
+        } catch (IOException e) {
+            throw ExceptionSupport.createMessageFormatException(e);
+        }
+    }
+
+    /**
+     * Reads an unsigned 8-bit number from the bytes message stream.
+     *
+     * @return the next byte from the bytes message stream, interpreted as an
+     *         unsigned 8-bit number
+     * @throws JMSException if the JMS provider fails to read the message due to
+     *                 some internal error.
+     * @throws MessageEOFException if unexpected end of bytes stream has been
+     *                 reached.
+     * @throws MessageNotReadableException if the message is in write-only mode.
+     */
+    @Override
+    public int readUnsignedByte() throws JMSException {
+        initializeReading();
+        try {
+            return this.dataIn.readUnsignedByte();
+        } catch (EOFException e) {
+            throw ExceptionSupport.createMessageEOFException(e);
+        } catch (IOException e) {
+            throw ExceptionSupport.createMessageFormatException(e);
+        }
+    }
+
+    /**
+     * Reads a signed 16-bit number from the bytes message stream.
+     *
+     * @return the next two bytes from the bytes message stream, interpreted as
+     *         a signed 16-bit number
+     * @throws JMSException if the JMS provider fails to read the message due to
+     *                 some internal error.
+     * @throws MessageEOFException if unexpected end of bytes stream has been
+     *                 reached.
+     * @throws MessageNotReadableException if the message is in write-only mode.
+     */
+    @Override
+    public short readShort() throws JMSException {
+        initializeReading();
+        try {
+            return this.dataIn.readShort();
+        } catch (EOFException e) {
+            throw ExceptionSupport.createMessageEOFException(e);
+        } catch (IOException e) {
+            throw ExceptionSupport.createMessageFormatException(e);
+        }
+    }
+
+    /**
+     * Reads an unsigned 16-bit number from the bytes message stream.
+     *
+     * @return the next two bytes from the bytes message stream, interpreted as
+     *         an unsigned 16-bit integer
+     * @throws JMSException if the JMS provider fails to read the message due to
+     *                 some internal error.
+     * @throws MessageEOFException if unexpected end of bytes stream has been
+     *                 reached.
+     * @throws MessageNotReadableException if the message is in write-only mode.
+     */
+    @Override
+    public int readUnsignedShort() throws JMSException {
+        initializeReading();
+        try {
+            return this.dataIn.readUnsignedShort();
+        } catch (EOFException e) {
+            throw ExceptionSupport.createMessageEOFException(e);
+        } catch (IOException e) {
+            throw ExceptionSupport.createMessageFormatException(e);
+        }
+    }
+
+    /**
+     * Reads a Unicode character value from the bytes message stream.
+     *
+     * @return the next two bytes from the bytes message stream as a Unicode
+     *         character
+     * @throws JMSException if the JMS provider fails to read the message due to
+     *                 some internal error.
+     * @throws MessageEOFException if unexpected end of bytes stream has been
+     *                 reached.
+     * @throws MessageNotReadableException if the message is in write-only mode.
+     */
+    @Override
+    public char readChar() throws JMSException {
+        initializeReading();
+        try {
+            return this.dataIn.readChar();
+        } catch (EOFException e) {
+            throw ExceptionSupport.createMessageEOFException(e);
+        } catch (IOException e) {
+            throw ExceptionSupport.createMessageFormatException(e);
+        }
+    }
+
+    /**
+     * Reads a signed 32-bit integer from the bytes message stream.
+     *
+     * @return the next four bytes from the bytes message stream, interpreted as
+     *         an <code>int</code>
+     * @throws JMSException if the JMS provider fails to read the message due to
+     *                 some internal error.
+     * @throws MessageEOFException if unexpected end of bytes stream has been
+     *                 reached.
+     * @throws MessageNotReadableException if the message is in write-only mode.
+     */
+    @Override
+    public int readInt() throws JMSException {
+        initializeReading();
+        try {
+            return this.dataIn.readInt();
+        } catch (EOFException e) {
+            throw ExceptionSupport.createMessageEOFException(e);
+        } catch (IOException e) {
+            throw ExceptionSupport.createMessageFormatException(e);
+        }
+    }
+
+    /**
+     * Reads a signed 64-bit integer from the bytes message stream.
+     *
+     * @return the next eight bytes from the bytes message stream, interpreted
+     *         as a <code>long</code>
+     * @throws JMSException if the JMS provider fails to read the message due to
+     *                 some internal error.
+     * @throws MessageEOFException if unexpected end of bytes stream has been
+     *                 reached.
+     * @throws MessageNotReadableException if the message is in write-only mode.
+     */
+    @Override
+    public long readLong() throws JMSException {
+        initializeReading();
+        try {
+            return this.dataIn.readLong();
+        } catch (EOFException e) {
+            throw ExceptionSupport.createMessageEOFException(e);
+        } catch (IOException e) {
+            throw ExceptionSupport.createMessageFormatException(e);
+        }
+    }
+
+    /**
+     * Reads a <code>float</code> from the bytes message stream.
+     *
+     * @return the next four bytes from the bytes message stream, interpreted as
+     *         a <code>float</code>
+     * @throws JMSException if the JMS provider fails to read the message due to
+     *                 some internal error.
+     * @throws MessageEOFException if unexpected end of bytes stream has been
+     *                 reached.
+     * @throws MessageNotReadableException if the message is in write-only mode.
+     */
+    @Override
+    public float readFloat() throws JMSException {
+        initializeReading();
+        try {
+            return this.dataIn.readFloat();
+        } catch (EOFException e) {
+            throw ExceptionSupport.createMessageEOFException(e);
+        } catch (IOException e) {
+            throw ExceptionSupport.createMessageFormatException(e);
+        }
+    }
+
+    /**
+     * Reads a <code>double</code> from the bytes message stream.
+     *
+     * @return the next eight bytes from the bytes message stream, interpreted
+     *         as a <code>double</code>
+     * @throws JMSException if the JMS provider fails to read the message due to
+     *                 some internal error.
+     * @throws MessageEOFException if unexpected end of bytes stream has been
+     *                 reached.
+     * @throws MessageNotReadableException if the message is in write-only mode.
+     */
+    @Override
+    public double readDouble() throws JMSException {
+        initializeReading();
+        try {
+            return this.dataIn.readDouble();
+        } catch (EOFException e) {
+            throw ExceptionSupport.createMessageEOFException(e);
+        } catch (IOException e) {
+            throw ExceptionSupport.createMessageFormatException(e);
+        }
+    }
+
+    /**
+     * Reads a string that has been encoded using a modified UTF-8 format from
+     * the bytes message stream.
+     * <P>
+     * For more information on the UTF-8 format, see "File System Safe UCS
+     * Transformation Format (FSS_UTF)", X/Open Preliminary Specification,
+     * X/Open Company Ltd., Document Number: P316. This information also appears
+     * in ISO/IEC 10646, Annex P.
+     *
+     * @return a Unicode string from the bytes message stream
+     * @throws JMSException if the JMS provider fails to read the message due to
+     *                 some internal error.
+     * @throws MessageEOFException if unexpected end of bytes stream has been
+     *                 reached.
+     * @throws MessageNotReadableException if the message is in write-only mode.
+     */
+    @Override
+    public String readUTF() throws JMSException {
+        initializeReading();
+        try {
+            return this.dataIn.readUTF();
+        } catch (EOFException e) {
+            throw ExceptionSupport.createMessageEOFException(e);
+        } catch (IOException e) {
+            throw ExceptionSupport.createMessageFormatException(e);
+        }
+    }
+
+    /**
+     * Reads a byte array from the bytes message stream.
+     * <P>
+     * If the length of array <code>value</code> is less than the number of
+     * bytes remaining to be read from the stream, the array should be filled. A
+     * subsequent call reads the next increment, and so on.
+     * <P>
+     * If the number of bytes remaining in the stream is less than the length of
+     * array <code>value</code>, the bytes should be read into the array. The
+     * return value of the total number of bytes read will be less than the
+     * length of the array, indicating that there are no more bytes left to be
+     * read from the stream. The next read of the stream returns -1.
+     *
+     * @param value the buffer into which the data is read
+     * @return the total number of bytes read into the buffer, or -1 if there is
+     *         no more data because the end of the stream has been reached
+     * @throws JMSException if the JMS provider fails to read the message due to
+     *                 some internal error.
+     * @throws MessageNotReadableException if the message is in write-only mode.
+     */
+    @Override
+    public int readBytes(byte[] value) throws JMSException {
+        return readBytes(value, value.length);
+    }
+
+    /**
+     * Reads a portion of the bytes message stream.
+     * <P>
+     * If the length of array <code>value</code> is less than the number of
+     * bytes remaining to be read from the stream, the array should be filled. A
+     * subsequent call reads the next increment, and so on.
+     * <P>
+     * If the number of bytes remaining in the stream is less than the length of
+     * array <code>value</code>, the bytes should be read into the array. The
+     * return value of the total number of bytes read will be less than the
+     * length of the array, indicating that there are no more bytes left to be
+     * read from the stream. The next read of the stream returns -1. <p/> If
+     * <code>length</code> is negative, or <code>length</code> is greater
+     * than the length of the array <code>value</code>, then an
+     * <code>IndexOutOfBoundsException</code> is thrown. No bytes will be read
+     * from the stream for this exception case.
+     *
+     * @param value the buffer into which the data is read
+     * @param length the number of bytes to read; must be less than or equal to
+     *                <code>value.length</code>
+     * @return the total number of bytes read into the buffer, or -1 if there is
+     *         no more data because the end of the stream has been reached
+     * @throws JMSException if the JMS provider fails to read the message due to
+     *                 some internal error.
+     * @throws MessageNotReadableException if the message is in write-only mode.
+     */
+    @Override
+    public int readBytes(byte[] value, int length) throws JMSException {
+        initializeReading();
+        try {
+            int n = 0;
+            while (n < length) {
+                int count = this.dataIn.read(value, n, length - n);
+                if (count < 0) {
+                    break;
+                }
+                n += count;
+            }
+            if (n == 0 && length > 0) {
+                n = -1;
+            }
+            return n;
+        } catch (EOFException e) {
+            throw ExceptionSupport.createMessageEOFException(e);
+        } catch (IOException e) {
+            throw ExceptionSupport.createMessageFormatException(e);
+        }
+    }
+
+    /**
+     * Writes a <code>boolean</code> to the bytes message stream as a 1-byte
+     * value. The value <code>true</code> is written as the value
+     * <code>(byte)1</code>; the value <code>false</code> is written as the
+     * value <code>(byte)0</code>.
+     *
+     * @param value the <code>boolean</code> value to be written
+     * @throws JMSException if the JMS provider fails to write the message due
+     *                 to some internal error.
+     * @throws MessageNotWriteableException if the message is in read-only mode.
+     */
+    @Override
+    public void writeBoolean(boolean value) throws JMSException {
+        initializeWriting();
+        try {
+            this.dataOut.writeBoolean(value);
+        } catch (IOException ioe) {
+            throw ExceptionSupport.create(ioe);
+        }
+    }
+
+    /**
+     * Writes a <code>byte</code> to the bytes message stream as a 1-byte
+     * value.
+     *
+     * @param value the <code>byte</code> value to be written
+     * @throws JMSException if the JMS provider fails to write the message due
+     *                 to some internal error.
+     * @throws MessageNotWriteableException if the message is in read-only mode.
+     */
+    @Override
+    public void writeByte(byte value) throws JMSException {
+        initializeWriting();
+        try {
+            this.dataOut.writeByte(value);
+        } catch (IOException ioe) {
+            throw ExceptionSupport.create(ioe);
+        }
+    }
+
+    /**
+     * Writes a <code>short</code> to the bytes message stream as two bytes,
+     * high byte first.
+     *
+     * @param value the <code>short</code> to be written
+     * @throws JMSException if the JMS provider fails to write the message due
+     *                 to some internal error.
+     * @throws MessageNotWriteableException if the message is in read-only mode.
+     */
+    @Override
+    public void writeShort(short value) throws JMSException {
+        initializeWriting();
+        try {
+            this.dataOut.writeShort(value);
+        } catch (IOException ioe) {
+            throw ExceptionSupport.create(ioe);
+        }
+    }
+
+    /**
+     * Writes a <code>char</code> to the bytes message stream as a 2-byte
+     * value, high byte first.
+     *
+     * @param value the <code>char</code> value to be written
+     * @throws JMSException if the JMS provider fails to write the message due
+     *                 to some internal error.
+     * @throws MessageNotWriteableException if the message is in read-only mode.
+     */
+    @Override
+    public void writeChar(char value) throws JMSException {
+        initializeWriting();
+        try {
+            this.dataOut.writeChar(value);
+        } catch (IOException ioe) {
+            throw ExceptionSupport.create(ioe);
+        }
+    }
+
+    /**
+     * Writes an <code>int</code> to the bytes message stream as four bytes,
+     * high byte first.
+     *
+     * @param value the <code>int</code> to be written
+     * @throws JMSException if the JMS provider fails to write the message due
+     *                 to some internal error.
+     * @throws MessageNotWriteableException if the message is in read-only mode.
+     */
+    @Override
+    public void writeInt(int value) throws JMSException {
+        initializeWriting();
+        try {
+            this.dataOut.writeInt(value);
+        } catch (IOException ioe) {
+            throw ExceptionSupport.create(ioe);
+        }
+    }
+
+    /**
+     * Writes a <code>long</code> to the bytes message stream as eight bytes,
+     * high byte first.
+     *
+     * @param value the <code>long</code> to be written
+     * @throws JMSException if the JMS provider fails to write the message due
+     *                 to some internal error.
+     * @throws MessageNotWriteableException if the message is in read-only mode.
+     */
+    @Override
+    public void writeLong(long value) throws JMSException {
+        initializeWriting();
+        try {
+            this.dataOut.writeLong(value);
+        } catch (IOException ioe) {
+            throw ExceptionSupport.create(ioe);
+        }
+    }
+
+    /**
+     * Converts the <code>float</code> argument to an <code>int</code> using
+     * the <code>floatToIntBits</code> method in class <code>Float</code>,
+     * and then writes that <code>int</code> value to the bytes message stream
+     * as a 4-byte quantity, high byte first.
+     *
+     * @param value the <code>float</code> value to be written
+     * @throws JMSException if the JMS provider fails to write the message due
+     *                 to some internal error.
+     * @throws MessageNotWriteableException if the message is in read-only mode.
+     */
+    @Override
+    public void writeFloat(float value) throws JMSException {
+        initializeWriting();
+        try {
+            this.dataOut.writeFloat(value);
+        } catch (IOException ioe) {
+            throw ExceptionSupport.create(ioe);
+        }
+    }
+
+    /**
+     * Converts the <code>double</code> argument to a <code>long</code>
+     * using the <code>doubleToLongBits</code> method in class
+     * <code>Double</code>, and then writes that <code>long</code> value to
+     * the bytes message stream as an 8-byte quantity, high byte first.
+     *
+     * @param value the <code>double</code> value to be written
+     * @throws JMSException if the JMS provider fails to write the message due
+     *                 to some internal error.
+     * @throws MessageNotWriteableException if the message is in read-only mode.
+     */
+    @Override
+    public void writeDouble(double value) throws JMSException {
+        initializeWriting();
+        try {
+            this.dataOut.writeDouble(value);
+        } catch (IOException ioe) {
+            throw ExceptionSupport.create(ioe);
+        }
+    }
+
+    /**
+     * Writes a string to the bytes message stream using UTF-8 encoding in a
+     * machine-independent manner.
+     * <P>
+     * For more information on the UTF-8 format, see "File System Safe UCS
+     * Transformation Format (FSS_UTF)", X/Open Preliminary Specification,
+     * X/Open Company Ltd., Document Number: P316. This information also appears
+     * in ISO/IEC 10646, Annex P.
+     *
+     * @param value the <code>String</code> value to be written
+     * @throws JMSException if the JMS provider fails to write the message due
+     *                 to some internal error.
+     * @throws MessageNotWriteableException if the message is in read-only mode.
+     */
+    @Override
+    public void writeUTF(String value) throws JMSException {
+        initializeWriting();
+        try {
+            this.dataOut.writeUTF(value);
+        } catch (IOException ioe) {
+            throw ExceptionSupport.create(ioe);
+        }
+    }
+
+    /**
+     * Writes a byte array to the bytes message stream.
+     *
+     * @param value the byte array to be written
+     * @throws JMSException if the JMS provider fails to write the message due
+     *                 to some internal error.
+     * @throws MessageNotWriteableException if the message is in read-only mode.
+     */
+    @Override
+    public void writeBytes(byte[] value) throws JMSException {
+        initializeWriting();
+        try {
+            this.dataOut.write(value);
+        } catch (IOException ioe) {
+            throw ExceptionSupport.create(ioe);
+        }
+    }
+
+    /**
+     * Writes a portion of a byte array to the bytes message stream.
+     *
+     * @param value the byte array value to be written
+     * @param offset the initial offset within the byte array
+     * @param length the number of bytes to use
+     * @throws JMSException if the JMS provider fails to write the message due
+     *                 to some internal error.
+     * @throws MessageNotWriteableException if the message is in read-only mode.
+     */
+    @Override
+    public void writeBytes(byte[] value, int offset, int length) throws JMSException {
+        initializeWriting();
+        try {
+            this.dataOut.write(value, offset, length);
+        } catch (IOException ioe) {
+            throw ExceptionSupport.create(ioe);
+        }
+    }
+
+    /**
+     * Writes an object to the bytes message stream.
+     * <P>
+     * This method works only for the objectified primitive object types (<code>Integer</code>,<code>Double</code>,
+     * <code>Long</code> &nbsp;...), <code>String</code> objects, and byte
+     * arrays.
+     *
+     * @param value the object in the Java programming language ("Java object")
+     *                to be written; it must not be null
+     * @throws JMSException if the JMS provider fails to write the message due
+     *                 to some internal error.
+     * @throws MessageFormatException if the object is of an invalid type.
+     * @throws MessageNotWriteableException if the message is in read-only mode.
+     * @throws java.lang.NullPointerException if the parameter
+     *                 <code>value</code> is null.
+     */
+    @Override
+    public void writeObject(Object value) throws JMSException {
+        if (value == null) {
+            throw new NullPointerException();
+        }
+        initializeWriting();
+        if (value instanceof Boolean) {
+            writeBoolean(((Boolean)value).booleanValue());
+        } else if (value instanceof Character) {
+            writeChar(((Character)value).charValue());
+        } else if (value instanceof Byte) {
+            writeByte(((Byte)value).byteValue());
+        } else if (value instanceof Short) {
+            writeShort(((Short)value).shortValue());
+        } else if (value instanceof Integer) {
+            writeInt(((Integer)value).intValue());
+        } else if (value instanceof Long) {
+            writeLong(((Long)value).longValue());
+        } else if (value instanceof Float) {
+            writeFloat(((Float)value).floatValue());
+        } else if (value instanceof Double) {
+            writeDouble(((Double)value).doubleValue());
+        } else if (value instanceof String) {
+            writeUTF(value.toString());
+        } else if (value instanceof byte[]) {
+            writeBytes((byte[])value);
+        } else {
+            throw new MessageFormatException("Cannot write non-primitive type:" + value.getClass());
+        }
+    }
+
+    @Override
+    public void reset() throws JMSException {
+        storeContent();
+        setReadOnlyBody(true);
+        try {
+            if (bytesOut != null) {
+                bytesOut.close();
+                bytesOut = null;
+            }
+            if (dataIn != null) {
+                dataIn.close();
+                dataIn = null;
+            }
+            if (dataOut != null) {
+                dataOut.close();
+                dataOut = null;
+            }
+        } catch (IOException ioe) {
+            throw ExceptionSupport.create(ioe);
+        }
+    }
+
+    private void initializeWriting() throws JMSException {
+        checkReadOnlyBody();
+        if (this.dataOut == null) {
+            this.bytesOut = new ByteArrayOutputStream();
+            OutputStream os = bytesOut;
+            this.dataOut = new DataOutputStream(os);
+        }
+
+        restoreOldContent();
+    }
+
+    private void restoreOldContent() throws JMSException {
+        // For a message that already had a body and was sent we need to restore the content
+        // if the message is used again without having its clearBody method called.
+        byte[] oldContent = message.getBodyBytes();
+        if (oldContent.length != 0) {
+            try {
+                dataOut.write(oldContent);
+            } catch (IOException e) {
+                throw ExceptionSupport.create(e);
+            }
+
+            // Clear old buffer as we are in write mode, only a call to reset can
+            // put us back in read mode and that will store any current pending
+            // content updates first.
+            message.clearBody();
+        }
+    }
+
+    private void initializeReading() throws JMSException {
+        checkWriteOnlyBody();
+        if (dataIn == null) {
+            try {
+                Buffer data = message.getPayload();
+                InputStream is = new ByteArrayInputStream(data);
+                length = data.length;
+                dataIn = new DataInputStream(is);
+            } catch (Exception ioe) {
+                throw ExceptionSupport.create(ioe);
+            }
+        }
+    }
+
+    private void storeContent() throws JMSException {
+        if (dataOut != null) {
+            try {
+                dataOut.close();
+                Buffer buffer = bytesOut.toBuffer();
+                message.setPayload(buffer);
+            } catch (IOException ioe) {
+                throw new RuntimeException(ioe.getMessage(), ioe);
+            } finally {
+                try {
+                    if (bytesOut != null) {
+                        bytesOut.close();
+                        bytesOut = null;
+                    }
+                    if (dataOut != null) {
+                        dataOut.close();
+                        dataOut = null;
+                    }
+                } catch (IOException ioe) {
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSMapMessage.java
----------------------------------------------------------------------
diff --git a/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSMapMessage.java b/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSMapMessage.java
new file mode 100644
index 0000000..a2fbd11
--- /dev/null
+++ b/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSMapMessage.java
@@ -0,0 +1,324 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jms;
+
+import java.util.Enumeration;
+
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.MessageFormatException;
+
+import org.apache.activemq.openwire.commands.OpenWireMapMessage;
+import org.fusesource.hawtbuf.UTF8Buffer;
+
+/**
+ * Wrapper class that provides MapMessage compliant mappings to the OpenWireMapMessage
+ */
+public class OpenWireJMSMapMessage extends OpenWireJMSMessage implements MapMessage {
+
+    private final OpenWireMapMessage message;
+
+    /**
+     * Creates a new instance that wraps a new OpenWireMessage instance.
+     */
+    public OpenWireJMSMapMessage() {
+        this(new OpenWireMapMessage());
+    }
+
+    /**
+     * Creates a new instance that wraps the given OpenWireMessage
+     *
+     * @param message
+     *        the OpenWireMessage to wrap.
+     */
+    public OpenWireJMSMapMessage(OpenWireMapMessage message) {
+        this.message = message;
+    }
+
+    @Override
+    public OpenWireJMSMapMessage copy() throws JMSException {
+        OpenWireJMSMapMessage other = new OpenWireJMSMapMessage(message.copy());
+        return other;
+    }
+
+    @Override
+    public void clearBody() throws JMSException {
+        super.clearBody();
+        message.clearBody();
+    }
+
+    @Override
+    public boolean getBoolean(String name) throws JMSException {
+        Object value = message.getObject(name);
+        if (value == null) {
+            return false;
+        }
+        if (value instanceof Boolean) {
+            return ((Boolean)value).booleanValue();
+        }
+        if (value instanceof UTF8Buffer) {
+            return Boolean.valueOf(value.toString()).booleanValue();
+        }
+        if (value instanceof String) {
+            return Boolean.valueOf(value.toString()).booleanValue();
+        } else {
+            throw new MessageFormatException(" cannot read a boolean from " + value.getClass().getName());
+        }
+    }
+
+    @Override
+    public byte getByte(String name) throws JMSException {
+        Object value = message.getObject(name);
+        if (value == null) {
+            return 0;
+        } else if (value instanceof Byte) {
+            return ((Byte)value).byteValue();
+        } else if (value instanceof UTF8Buffer) {
+            return Byte.valueOf(value.toString()).byteValue();
+        } else if (value instanceof String) {
+            return Byte.valueOf(value.toString()).byteValue();
+        } else {
+            throw new MessageFormatException(" cannot read a byte from " + value.getClass().getName());
+        }
+    }
+
+    @Override
+    public short getShort(String name) throws JMSException {
+        Object value = message.getObject(name);
+        if (value == null) {
+            return 0;
+        } else if (value instanceof Short) {
+            return ((Short)value).shortValue();
+        } else if (value instanceof Byte) {
+            return ((Byte)value).shortValue();
+        } else if (value instanceof UTF8Buffer) {
+            return Short.valueOf(value.toString()).shortValue();
+        } else if (value instanceof String) {
+            return Short.valueOf(value.toString()).shortValue();
+        } else {
+            throw new MessageFormatException(" cannot read a short from " + value.getClass().getName());
+        }
+    }
+
+    @Override
+    public char getChar(String name) throws JMSException {
+        Object value = message.getObject(name);
+        if (value == null) {
+            throw new NullPointerException();
+        } else if (value instanceof Character) {
+            return ((Character)value).charValue();
+        } else {
+            throw new MessageFormatException(" cannot read a short from " + value.getClass().getName());
+        }
+    }
+
+    @Override
+    public int getInt(String name) throws JMSException {
+        Object value = message.getObject(name);
+        if (value == null) {
+            return 0;
+        } else if (value instanceof Integer) {
+            return ((Integer)value).intValue();
+        } else if (value instanceof Short) {
+            return ((Short)value).intValue();
+        } else if (value instanceof Byte) {
+            return ((Byte)value).intValue();
+        } else if (value instanceof UTF8Buffer) {
+            return Integer.valueOf(value.toString()).intValue();
+        } else if (value instanceof String) {
+            return Integer.valueOf(value.toString()).intValue();
+        } else {
+            throw new MessageFormatException(" cannot read an int from " + value.getClass().getName());
+        }
+    }
+
+    @Override
+    public long getLong(String name) throws JMSException {
+        Object value = message.getObject(name);
+        if (value == null) {
+            return 0;
+        } else if (value instanceof Long) {
+            return ((Long)value).longValue();
+        } else if (value instanceof Integer) {
+            return ((Integer)value).longValue();
+        } else if (value instanceof Short) {
+            return ((Short)value).longValue();
+        } else if (value instanceof Byte) {
+            return ((Byte)value).longValue();
+        } else if (value instanceof UTF8Buffer) {
+            return Long.valueOf(value.toString()).longValue();
+        } else if (value instanceof String) {
+            return Long.valueOf(value.toString()).longValue();
+        } else {
+            throw new MessageFormatException(" cannot read a long from " + value.getClass().getName());
+        }
+    }
+
+    @Override
+    public float getFloat(String name) throws JMSException {
+        Object value = message.getObject(name);
+        if (value == null) {
+            return 0;
+        } else if (value instanceof Float) {
+            return ((Float)value).floatValue();
+        } else if (value instanceof UTF8Buffer) {
+            return Float.valueOf(value.toString()).floatValue();
+        } else if (value instanceof String) {
+            return Float.valueOf(value.toString()).floatValue();
+        } else {
+            throw new MessageFormatException(" cannot read a float from " + value.getClass().getName());
+        }
+    }
+
+    @Override
+    public double getDouble(String name) throws JMSException {
+        Object value = message.getObject(name);
+        if (value == null) {
+            return 0;
+        } else if (value instanceof Double) {
+            return ((Double)value).doubleValue();
+        } else if (value instanceof Float) {
+            return ((Float)value).floatValue();
+        } else if (value instanceof UTF8Buffer) {
+            return Float.valueOf(value.toString()).floatValue();
+        } else if (value instanceof String) {
+            return Float.valueOf(value.toString()).floatValue();
+        } else {
+            throw new MessageFormatException(" cannot read a double from " + value.getClass().getName());
+        }
+    }
+
+    @Override
+    public String getString(String name) throws JMSException {
+        Object value = message.getObject(name);
+        if (value == null) {
+            return null;
+        } else if (value instanceof byte[]) {
+            throw new MessageFormatException("Use getBytes to read a byte array");
+        } else {
+            return value.toString();
+        }
+    }
+
+    @Override
+    public byte[] getBytes(String name) throws JMSException {
+        Object value = message.getObject(name);
+        if (value instanceof byte[]) {
+            return (byte[])value;
+        } else {
+            throw new MessageFormatException(" cannot read a byte[] from " + value.getClass().getName());
+        }
+    }
+
+    @Override
+    public Object getObject(String name) throws JMSException {
+        Object value = message.getObject(name);
+        if (value instanceof UTF8Buffer) {
+            value = value.toString();
+        }
+
+        return value;
+    }
+
+    @Override
+    public Enumeration<String> getMapNames() throws JMSException {
+        return message.getMapNames();
+    }
+
+    @Override
+    public void setBoolean(String name, boolean value) throws JMSException {
+        checkReadOnlyBody();
+        message.setObject(name, value ? Boolean.TRUE : Boolean.FALSE);
+    }
+
+    @Override
+    public void setByte(String name, byte value) throws JMSException {
+        checkReadOnlyBody();
+        message.setObject(name, Byte.valueOf(value));
+    }
+
+    @Override
+    public void setShort(String name, short value) throws JMSException {
+        checkReadOnlyBody();
+        message.setObject(name, Short.valueOf(value));
+    }
+
+    @Override
+    public void setChar(String name, char value) throws JMSException {
+        checkReadOnlyBody();
+        message.setObject(name, Character.valueOf(value));
+    }
+
+    @Override
+    public void setInt(String name, int value) throws JMSException {
+        checkReadOnlyBody();
+        message.setObject(name, Integer.valueOf(value));
+    }
+
+    @Override
+    public void setLong(String name, long value) throws JMSException {
+        checkReadOnlyBody();
+        message.setObject(name, Long.valueOf(value));
+    }
+
+    @Override
+    public void setFloat(String name, float value) throws JMSException {
+        checkReadOnlyBody();
+        message.setObject(name, Float.valueOf(value));
+    }
+
+    @Override
+    public void setDouble(String name, double value) throws JMSException {
+        checkReadOnlyBody();
+        message.setObject(name, Double.valueOf(value));
+    }
+
+    @Override
+    public void setString(String name, String value) throws JMSException {
+        checkReadOnlyBody();
+        message.setObject(name, value);
+    }
+
+    @Override
+    public void setBytes(String name, byte[] value) throws JMSException {
+        checkReadOnlyBody();
+        if (value != null) {
+            message.setObject(name, value);
+        } else {
+            message.removeObject(name);
+        }
+    }
+
+    @Override
+    public void setBytes(String name, byte[] value, int offset, int length) throws JMSException {
+        checkReadOnlyBody();
+        byte[] data = new byte[length];
+        System.arraycopy(value, offset, data, 0, length);
+        message.setObject(name, data);
+    }
+
+    @Override
+    public void setObject(String name, Object value) throws JMSException {
+        checkReadOnlyBody();
+        message.setObject(name, value);
+    }
+
+    @Override
+    public boolean itemExists(String name) throws JMSException {
+        return message.itemExists(name);
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSMessage.java
----------------------------------------------------------------------
diff --git a/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSMessage.java b/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSMessage.java
new file mode 100644
index 0000000..a278f37
--- /dev/null
+++ b/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSMessage.java
@@ -0,0 +1,561 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jms;
+
+import java.util.Enumeration;
+import java.util.Vector;
+import java.util.concurrent.Callable;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageFormatException;
+import javax.jms.MessageNotReadableException;
+import javax.jms.MessageNotWriteableException;
+
+import org.apache.activemq.openwire.codec.OpenWireConstants;
+import org.apache.activemq.openwire.commands.OpenWireDestination;
+import org.apache.activemq.openwire.commands.OpenWireMessage;
+import org.apache.activemq.openwire.jms.utils.OpenWireMessagePropertyGetter;
+import org.apache.activemq.openwire.jms.utils.OpenWireMessagePropertySetter;
+import org.apache.activemq.openwire.jms.utils.TypeConversionSupport;
+import org.apache.activemq.openwire.utils.ExceptionSupport;
+import org.fusesource.hawtbuf.UTF8Buffer;
+
+/**
+ * A JMS Message implementation that wraps the basic OpenWireMessage instance
+ * to enforce adherence to the JMS specification rules for the javax.jms.Message
+ * type.
+ */
+public class OpenWireJMSMessage implements Message {
+
+    private final OpenWireMessage message;
+
+    private Callable<Void> acknowledgeCallback;
+    private boolean readOnlyBody;
+    private boolean readOnlyProperties;
+
+    /**
+     * Creates a new instance that wraps a new OpenWireMessage instance.
+     */
+    public OpenWireJMSMessage() {
+        this(new OpenWireMessage());
+    }
+
+    /**
+     * Creates a new instance that wraps the given OpenWireMessage
+     *
+     * @param message
+     *        the OpenWireMessage to wrap.
+     */
+    public OpenWireJMSMessage(OpenWireMessage message) {
+        this.message = message;
+    }
+
+    /**
+     * Copies this message into a new OpenWireJMSMessage instance.
+     *
+     * @return a new copy of this message and it's contents.
+     *
+     * @throws JMSException if an error occurs during the copy operation.
+     */
+    public OpenWireJMSMessage copy() throws JMSException {
+        OpenWireJMSMessage copy = new OpenWireJMSMessage(message.copy());
+        copy(copy);
+        return copy;
+    }
+
+    protected void copy(OpenWireJMSMessage copy) {
+        copy.readOnlyBody = readOnlyBody;
+        copy.readOnlyProperties = readOnlyProperties;
+    }
+
+    /**
+     * @return the wrapped OpenWireMessage instance.
+     */
+    public OpenWireMessage getOpenWireMessage() {
+        return this.message;
+    }
+
+    @Override
+    public String getJMSMessageID() throws JMSException {
+        return message.getMessageIdAsString();
+    }
+
+    @Override
+    public void setJMSMessageID(String id) throws JMSException {
+        message.setMessageId(id);
+    }
+
+    @Override
+    public long getJMSTimestamp() throws JMSException {
+        return message.getTimestamp();
+    }
+
+    @Override
+    public void setJMSTimestamp(long timestamp) throws JMSException {
+        message.setTimestamp(timestamp);
+    }
+
+    @Override
+    public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
+        return message.getCorrelationIdAsBytes();
+    }
+
+    @Override
+    public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException {
+        message.setCorrelationIdAsBytes(correlationID);
+    }
+
+    @Override
+    public void setJMSCorrelationID(String correlationID) throws JMSException {
+        message.setCorrelationId(correlationID);
+    }
+
+    @Override
+    public String getJMSCorrelationID() throws JMSException {
+        return message.getCorrelationId();
+    }
+
+    @Override
+    public Destination getJMSReplyTo() throws JMSException {
+        return message.getReplyTo();
+    }
+
+    @Override
+    public void setJMSReplyTo(Destination replyTo) throws JMSException {
+        message.setReplyTo(OpenWireDestination.transform(replyTo));
+    }
+
+    @Override
+    public Destination getJMSDestination() throws JMSException {
+        return message.getDestination();
+    }
+
+    @Override
+    public void setJMSDestination(Destination destination) throws JMSException {
+        message.setDestination(OpenWireDestination.transform(destination));
+    }
+
+    @Override
+    public int getJMSDeliveryMode() throws JMSException {
+        return message.isPersistent() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
+    }
+
+    @Override
+    public void setJMSDeliveryMode(int deliveryMode) throws JMSException {
+        message.setPersistent(deliveryMode == DeliveryMode.PERSISTENT);
+    }
+
+    @Override
+    public boolean getJMSRedelivered() throws JMSException {
+        return message.getRedeliveryCounter() > 0;
+    }
+
+    @Override
+    public void setJMSRedelivered(boolean redelivered) throws JMSException {
+        message.setRedelivered(true);
+    }
+
+    @Override
+    public String getJMSType() throws JMSException {
+        return message.getType();
+    }
+
+    @Override
+    public void setJMSType(String type) throws JMSException {
+        message.setType(type);
+    }
+
+    @Override
+    public long getJMSExpiration() throws JMSException {
+        return message.getExpiration();
+    }
+
+    @Override
+    public void setJMSExpiration(long expiration) throws JMSException {
+        message.setExpiration(expiration);
+    }
+
+    @Override
+    public int getJMSPriority() throws JMSException {
+        return message.getPriority();
+    }
+
+    @Override
+    public void setJMSPriority(int priority) throws JMSException {
+        message.setPriority((byte) priority);
+    }
+
+    @Override
+    public void clearProperties() throws JMSException {
+        message.clearProperties();
+    }
+
+    @Override
+    public boolean propertyExists(String name) throws JMSException {
+        try {
+            return (message.propertyExists(name) || getObjectProperty(name)!= null);
+        } catch (Exception e) {
+            throw ExceptionSupport.create(e);
+        }
+    }
+
+    @Override
+    public boolean getBooleanProperty(String name) throws JMSException {
+        Object value = getObjectProperty(name);
+
+        if (value == null) {
+            return false;
+        }
+
+        Boolean rc = (Boolean) TypeConversionSupport.convert(value, Boolean.class);
+        if (rc == null) {
+            throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a boolean");
+        }
+
+        return rc.booleanValue();
+    }
+
+    @Override
+    public byte getByteProperty(String name) throws JMSException {
+        Object value = getObjectProperty(name);
+        if (value == null) {
+            throw new NumberFormatException("property " + name + " was null");
+        }
+        Byte rc = (Byte) TypeConversionSupport.convert(value, Byte.class);
+        if (rc == null) {
+            throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a byte");
+        }
+        return rc.byteValue();
+    }
+
+    @Override
+    public short getShortProperty(String name) throws JMSException {
+        Object value = getObjectProperty(name);
+        if (value == null) {
+            throw new NumberFormatException("property " + name + " was null");
+        }
+        Short rc = (Short) TypeConversionSupport.convert(value, Short.class);
+        if (rc == null) {
+            throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a short");
+        }
+        return rc.shortValue();
+    }
+
+    @Override
+    public int getIntProperty(String name) throws JMSException {
+        Object value = getObjectProperty(name);
+        if (value == null) {
+            throw new NumberFormatException("property " + name + " was null");
+        }
+        Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
+        if (rc == null) {
+            throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as an integer");
+        }
+        return rc.intValue();
+    }
+
+    @Override
+    public long getLongProperty(String name) throws JMSException {
+        Object value = getObjectProperty(name);
+        if (value == null) {
+            throw new NumberFormatException("property " + name + " was null");
+        }
+        Long rc = (Long) TypeConversionSupport.convert(value, Long.class);
+        if (rc == null) {
+            throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a long");
+        }
+        return rc.longValue();
+    }
+
+    @Override
+    public float getFloatProperty(String name) throws JMSException {
+        Object value = getObjectProperty(name);
+        if (value == null) {
+            throw new NullPointerException("property " + name + " was null");
+        }
+        Float rc = (Float) TypeConversionSupport.convert(value, Float.class);
+        if (rc == null) {
+            throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a float");
+        }
+        return rc.floatValue();
+    }
+
+    @Override
+    public double getDoubleProperty(String name) throws JMSException {
+        Object value = getObjectProperty(name);
+        if (value == null) {
+            throw new NullPointerException("property " + name + " was null");
+        }
+        Double rc = (Double) TypeConversionSupport.convert(value, Double.class);
+        if (rc == null) {
+            throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a double");
+        }
+        return rc.doubleValue();
+    }
+
+    @Override
+    public String getStringProperty(String name) throws JMSException {
+        Object value = null;
+
+        // Always go first to the OpenWire Message field before checking in the
+        // application properties for any other versions.
+        if (name.equals("JMSXUserID")) {
+            value = message.getUserId();
+            if (value == null) {
+                value = getObjectProperty(name);
+            }
+        } else {
+            value = getObjectProperty(name);
+        }
+        if (value == null) {
+            return null;
+        }
+        String rc = (String) TypeConversionSupport.convert(value, String.class);
+        if (rc == null) {
+            throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a String");
+        }
+        return rc;
+    }
+
+    @Override
+    public Object getObjectProperty(String name) throws JMSException {
+        if (name == null) {
+            throw new NullPointerException("Property name cannot be null");
+        }
+
+        return OpenWireMessagePropertyGetter.getProperty(message, name);
+    }
+
+    @Override
+    public Enumeration<?> getPropertyNames() throws JMSException {
+        return message.getPropertyNames();
+    }
+
+    /**
+     * return all property names, including standard JMS properties and JMSX properties
+     * @return  Enumeration of all property names on this message
+     * @throws JMSException
+     */
+    public Enumeration<String> getAllPropertyNames() throws JMSException {
+        try {
+            Vector<String> result = new Vector<String>(message.getProperties().keySet());
+            result.addAll(OpenWireMessagePropertyGetter.getPropertyNames());
+            return result.elements();
+        } catch (Exception e) {
+            throw ExceptionSupport.create(e);
+        }
+    }
+
+    @Override
+    public void setBooleanProperty(String name, boolean value) throws JMSException {
+        setObjectProperty(name, Boolean.valueOf(value), true);
+    }
+
+    @Override
+    public void setByteProperty(String name, byte value) throws JMSException {
+        setObjectProperty(name, Byte.valueOf(value), true);
+    }
+
+    @Override
+    public void setShortProperty(String name, short value) throws JMSException {
+        setObjectProperty(name, Short.valueOf(value), true);
+    }
+
+    @Override
+    public void setIntProperty(String name, int value) throws JMSException {
+        setObjectProperty(name, Integer.valueOf(value), true);
+    }
+
+    @Override
+    public void setLongProperty(String name, long value) throws JMSException {
+        setObjectProperty(name, Long.valueOf(value), true);
+    }
+
+    @Override
+    public void setFloatProperty(String name, float value) throws JMSException {
+        setObjectProperty(name, Float.valueOf(value), true);
+    }
+
+    @Override
+    public void setDoubleProperty(String name, double value) throws JMSException {
+        setObjectProperty(name, Double.valueOf(value), true);
+    }
+
+    @Override
+    public void setStringProperty(String name, String value) throws JMSException {
+        setObjectProperty(name, value, true);
+    }
+
+    @Override
+    public void setObjectProperty(String name, Object value) throws JMSException {
+        setObjectProperty(name, value, true);
+    }
+
+    protected void setObjectProperty(String name, Object value, boolean checkReadOnly) throws JMSException {
+
+        if (checkReadOnly) {
+            checkReadOnlyProperties();
+        }
+
+        if (name == null || name.equals("")) {
+            throw new IllegalArgumentException("Property name cannot be empty or null");
+        }
+
+        if (value instanceof UTF8Buffer) {
+            value = value.toString();
+        }
+
+        // Ensure that message sent with scheduling options comply with the
+        // expected property types for the settings values.
+        value = convertScheduled(name, value);
+
+        OpenWireMessagePropertySetter.setProperty(message, name, value);
+    }
+
+    @Override
+    public void acknowledge() throws JMSException {
+        if (acknowledgeCallback != null) {
+            try {
+                acknowledgeCallback.call();
+            } catch (Exception e) {
+                throw ExceptionSupport.create(e);
+            }
+        }
+    }
+
+    @Override
+    public void clearBody() throws JMSException {
+        setReadOnlyBody(false);
+    }
+
+    /**
+     * @return the acknowledge callback instance set on this message.
+     */
+    public Callable<Void> getAcknowledgeCallback() {
+        return acknowledgeCallback;
+    }
+
+    /**
+     * Sets the Callable instance that is invoked when the client calls the JMS Message
+     * acknowledge method.
+     *
+     * @param acknowledgeCallback
+     *        the acknowledgeCallback to set on this message.
+     */
+    public void setAcknowledgeCallback(Callable<Void> acknowledgeCallback) {
+        this.acknowledgeCallback = acknowledgeCallback;
+    }
+
+    /**
+     * @return true if the body is in read only mode.
+     */
+    public boolean isReadOnlyBody() {
+        return readOnlyBody;
+    }
+
+    /**
+     * @param readOnlyBody
+     *        sets if the message body is in read-only mode.
+     */
+    public void setReadOnlyBody(boolean readOnlyBody) {
+        this.readOnlyBody = readOnlyBody;
+    }
+
+    /**
+     * @return true if the message properties are in read-only mode.
+     */
+    public boolean isReadOnlyProperties() {
+        return readOnlyProperties;
+    }
+
+    /**
+     * @param readOnlyProperties
+     *        sets if the message properties are in read-only mode.
+     */
+    public void setReadOnlyProperties(boolean readOnlyProperties) {
+        this.readOnlyProperties = readOnlyProperties;
+    }
+
+    /**
+     * @returns true if this message has expired.
+     */
+    public boolean isExpired() {
+        return message.isExpired();
+    }
+
+    /**
+     * @returns true if this message is an Advisory message instance.
+     */
+    public boolean isAdviory() {
+        return this.message.isAdvisory();
+    }
+
+    @Override
+    public int hashCode() {
+        return message.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+
+        if (other == null || other.getClass() != getClass()) {
+            return false;
+        }
+
+        OpenWireJMSMessage jmsMessage = (OpenWireJMSMessage) other;
+
+        return message.equals(jmsMessage.getOpenWireMessage());
+    }
+
+    private void checkReadOnlyProperties() throws MessageNotWriteableException {
+        if (readOnlyProperties) {
+            throw new MessageNotWriteableException("Message properties are read-only");
+        }
+    }
+
+    protected void checkReadOnlyBody() throws MessageNotWriteableException {
+        if (readOnlyBody) {
+            throw new MessageNotWriteableException("Message body is read-only");
+        }
+    }
+
+    protected void checkWriteOnlyBody() throws MessageNotReadableException {
+        if (!readOnlyBody) {
+            throw new MessageNotReadableException("Message body is write-only");
+        }
+    }
+
+    protected Object convertScheduled(String name, Object value) throws MessageFormatException {
+        Object result = value;
+        if (OpenWireConstants.AMQ_SCHEDULED_DELAY.equals(name)){
+            result = TypeConversionSupport.convert(value, Long.class);
+        }
+        else if (OpenWireConstants.AMQ_SCHEDULED_PERIOD.equals(name)){
+            result = TypeConversionSupport.convert(value, Long.class);
+        }
+        else if (OpenWireConstants.AMQ_SCHEDULED_REPEAT.equals(name)){
+            result = TypeConversionSupport.convert(value, Integer.class);
+        }
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSObjectMessage.java
----------------------------------------------------------------------
diff --git a/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSObjectMessage.java b/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSObjectMessage.java
new file mode 100644
index 0000000..db42806
--- /dev/null
+++ b/openwire-jms/src/main/java/org/apache/activemq/openwire/jms/OpenWireJMSObjectMessage.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jms;
+
+import java.io.Serializable;
+
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+
+import org.apache.activemq.openwire.commands.OpenWireObjectMessage;
+
+/**
+ * Wrapper class that provides ObjectMessage compliant mappings to the OpenWireObjectMessage
+ */
+public class OpenWireJMSObjectMessage extends OpenWireJMSMessage implements ObjectMessage {
+
+    private final OpenWireObjectMessage message;
+
+    /**
+     * Creates a new instance that wraps a new OpenWireMessage instance.
+     */
+    public OpenWireJMSObjectMessage() {
+        this(new OpenWireObjectMessage());
+    }
+
+    /**
+     * Creates a new instance that wraps the given OpenWireMessage
+     *
+     * @param message
+     *        the OpenWireMessage to wrap.
+     */
+    public OpenWireJMSObjectMessage(OpenWireObjectMessage message) {
+        this.message = message;
+    }
+
+    @Override
+    public void clearBody() throws JMSException {
+        super.clearBody();
+        message.clearBody();
+    }
+
+    @Override
+    public OpenWireJMSObjectMessage copy() throws JMSException {
+        OpenWireJMSObjectMessage other = new OpenWireJMSObjectMessage(message.copy());
+        return other;
+    }
+
+    @Override
+    public void setObject(Serializable object) throws JMSException {
+        checkReadOnlyBody();
+        message.setObject(object);
+    }
+
+    @Override
+    public Serializable getObject() throws JMSException {
+        return message.getObject();
+    }
+}


Mime
View raw message