mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1410580 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6c8e89652f
commit
543935b6e9
|
@ -46,6 +46,11 @@
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
<artifactId>geronimo-jms_1.1_spec</artifactId>
|
<artifactId>geronimo-jms_1.1_spec</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.fusesource.hawtbuf</groupId>
|
||||||
|
<artifactId>hawtbuf</artifactId>
|
||||||
|
<version>${hawtbuf-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- would be nice if we could make this dependency optional -->
|
<!-- would be nice if we could make this dependency optional -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -41,6 +41,7 @@ import org.apache.activemq.util.ByteSequence;
|
||||||
import org.apache.activemq.util.JMSExceptionSupport;
|
import org.apache.activemq.util.JMSExceptionSupport;
|
||||||
import org.apache.activemq.util.MarshallingSupport;
|
import org.apache.activemq.util.MarshallingSupport;
|
||||||
import org.apache.activemq.wireformat.WireFormat;
|
import org.apache.activemq.wireformat.WireFormat;
|
||||||
|
import org.fusesource.hawtbuf.UTF8Buffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A <CODE>MapMessage</CODE> object is used to send a set of name-value pairs.
|
* A <CODE>MapMessage</CODE> object is used to send a set of name-value pairs.
|
||||||
|
@ -109,6 +110,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Message copy() {
|
public Message copy() {
|
||||||
ActiveMQMapMessage copy = new ActiveMQMapMessage();
|
ActiveMQMapMessage copy = new ActiveMQMapMessage();
|
||||||
copy(copy);
|
copy(copy);
|
||||||
|
@ -121,11 +123,13 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// We only need to marshal the content if we are hitting the wire.
|
// We only need to marshal the content if we are hitting the wire.
|
||||||
|
@Override
|
||||||
public void beforeMarshall(WireFormat wireFormat) throws IOException {
|
public void beforeMarshall(WireFormat wireFormat) throws IOException {
|
||||||
super.beforeMarshall(wireFormat);
|
super.beforeMarshall(wireFormat);
|
||||||
storeContent();
|
storeContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void clearMarshalledState() throws JMSException {
|
public void clearMarshalledState() throws JMSException {
|
||||||
super.clearMarshalledState();
|
super.clearMarshalledState();
|
||||||
map.clear();
|
map.clear();
|
||||||
|
@ -175,10 +179,12 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte getDataStructureType() {
|
public byte getDataStructureType() {
|
||||||
return DATA_STRUCTURE_TYPE;
|
return DATA_STRUCTURE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getJMSXMimeType() {
|
public String getJMSXMimeType() {
|
||||||
return "jms/map-message";
|
return "jms/map-message";
|
||||||
}
|
}
|
||||||
|
@ -191,6 +197,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* message body in the same state as an empty body in a newly created
|
* message body in the same state as an empty body in a newly created
|
||||||
* message.
|
* message.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void clearBody() throws JMSException {
|
public void clearBody() throws JMSException {
|
||||||
super.clearBody();
|
super.clearBody();
|
||||||
map.clear();
|
map.clear();
|
||||||
|
@ -205,6 +212,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* some internal error.
|
* some internal error.
|
||||||
* @throws MessageFormatException if this type conversion is invalid.
|
* @throws MessageFormatException if this type conversion is invalid.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getBoolean(String name) throws JMSException {
|
public boolean getBoolean(String name) throws JMSException {
|
||||||
initializeReading();
|
initializeReading();
|
||||||
Object value = map.get(name);
|
Object value = map.get(name);
|
||||||
|
@ -214,6 +222,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
if (value instanceof Boolean) {
|
if (value instanceof Boolean) {
|
||||||
return ((Boolean)value).booleanValue();
|
return ((Boolean)value).booleanValue();
|
||||||
}
|
}
|
||||||
|
if (value instanceof UTF8Buffer) {
|
||||||
|
return Boolean.valueOf(value.toString()).booleanValue();
|
||||||
|
}
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
return Boolean.valueOf(value.toString()).booleanValue();
|
return Boolean.valueOf(value.toString()).booleanValue();
|
||||||
} else {
|
} else {
|
||||||
|
@ -230,6 +241,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* some internal error.
|
* some internal error.
|
||||||
* @throws MessageFormatException if this type conversion is invalid.
|
* @throws MessageFormatException if this type conversion is invalid.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public byte getByte(String name) throws JMSException {
|
public byte getByte(String name) throws JMSException {
|
||||||
initializeReading();
|
initializeReading();
|
||||||
Object value = map.get(name);
|
Object value = map.get(name);
|
||||||
|
@ -239,6 +251,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
if (value instanceof Byte) {
|
if (value instanceof Byte) {
|
||||||
return ((Byte)value).byteValue();
|
return ((Byte)value).byteValue();
|
||||||
}
|
}
|
||||||
|
if (value instanceof UTF8Buffer) {
|
||||||
|
return Byte.valueOf(value.toString()).byteValue();
|
||||||
|
}
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
return Byte.valueOf(value.toString()).byteValue();
|
return Byte.valueOf(value.toString()).byteValue();
|
||||||
} else {
|
} else {
|
||||||
|
@ -255,6 +270,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* some internal error.
|
* some internal error.
|
||||||
* @throws MessageFormatException if this type conversion is invalid.
|
* @throws MessageFormatException if this type conversion is invalid.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public short getShort(String name) throws JMSException {
|
public short getShort(String name) throws JMSException {
|
||||||
initializeReading();
|
initializeReading();
|
||||||
Object value = map.get(name);
|
Object value = map.get(name);
|
||||||
|
@ -267,6 +283,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
if (value instanceof Byte) {
|
if (value instanceof Byte) {
|
||||||
return ((Byte)value).shortValue();
|
return ((Byte)value).shortValue();
|
||||||
}
|
}
|
||||||
|
if (value instanceof UTF8Buffer) {
|
||||||
|
return Short.valueOf(value.toString()).shortValue();
|
||||||
|
}
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
return Short.valueOf(value.toString()).shortValue();
|
return Short.valueOf(value.toString()).shortValue();
|
||||||
} else {
|
} else {
|
||||||
|
@ -283,6 +302,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* some internal error.
|
* some internal error.
|
||||||
* @throws MessageFormatException if this type conversion is invalid.
|
* @throws MessageFormatException if this type conversion is invalid.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public char getChar(String name) throws JMSException {
|
public char getChar(String name) throws JMSException {
|
||||||
initializeReading();
|
initializeReading();
|
||||||
Object value = map.get(name);
|
Object value = map.get(name);
|
||||||
|
@ -305,6 +325,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* some internal error.
|
* some internal error.
|
||||||
* @throws MessageFormatException if this type conversion is invalid.
|
* @throws MessageFormatException if this type conversion is invalid.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getInt(String name) throws JMSException {
|
public int getInt(String name) throws JMSException {
|
||||||
initializeReading();
|
initializeReading();
|
||||||
Object value = map.get(name);
|
Object value = map.get(name);
|
||||||
|
@ -320,6 +341,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
if (value instanceof Byte) {
|
if (value instanceof Byte) {
|
||||||
return ((Byte)value).intValue();
|
return ((Byte)value).intValue();
|
||||||
}
|
}
|
||||||
|
if (value instanceof UTF8Buffer) {
|
||||||
|
return Integer.valueOf(value.toString()).intValue();
|
||||||
|
}
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
return Integer.valueOf(value.toString()).intValue();
|
return Integer.valueOf(value.toString()).intValue();
|
||||||
} else {
|
} else {
|
||||||
|
@ -336,6 +360,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* some internal error.
|
* some internal error.
|
||||||
* @throws MessageFormatException if this type conversion is invalid.
|
* @throws MessageFormatException if this type conversion is invalid.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public long getLong(String name) throws JMSException {
|
public long getLong(String name) throws JMSException {
|
||||||
initializeReading();
|
initializeReading();
|
||||||
Object value = map.get(name);
|
Object value = map.get(name);
|
||||||
|
@ -354,6 +379,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
if (value instanceof Byte) {
|
if (value instanceof Byte) {
|
||||||
return ((Byte)value).longValue();
|
return ((Byte)value).longValue();
|
||||||
}
|
}
|
||||||
|
if (value instanceof UTF8Buffer) {
|
||||||
|
return Long.valueOf(value.toString()).longValue();
|
||||||
|
}
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
return Long.valueOf(value.toString()).longValue();
|
return Long.valueOf(value.toString()).longValue();
|
||||||
} else {
|
} else {
|
||||||
|
@ -370,6 +398,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* some internal error.
|
* some internal error.
|
||||||
* @throws MessageFormatException if this type conversion is invalid.
|
* @throws MessageFormatException if this type conversion is invalid.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public float getFloat(String name) throws JMSException {
|
public float getFloat(String name) throws JMSException {
|
||||||
initializeReading();
|
initializeReading();
|
||||||
Object value = map.get(name);
|
Object value = map.get(name);
|
||||||
|
@ -379,6 +408,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
if (value instanceof Float) {
|
if (value instanceof Float) {
|
||||||
return ((Float)value).floatValue();
|
return ((Float)value).floatValue();
|
||||||
}
|
}
|
||||||
|
if (value instanceof UTF8Buffer) {
|
||||||
|
return Float.valueOf(value.toString()).floatValue();
|
||||||
|
}
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
return Float.valueOf(value.toString()).floatValue();
|
return Float.valueOf(value.toString()).floatValue();
|
||||||
} else {
|
} else {
|
||||||
|
@ -395,6 +427,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* some internal error.
|
* some internal error.
|
||||||
* @throws MessageFormatException if this type conversion is invalid.
|
* @throws MessageFormatException if this type conversion is invalid.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public double getDouble(String name) throws JMSException {
|
public double getDouble(String name) throws JMSException {
|
||||||
initializeReading();
|
initializeReading();
|
||||||
Object value = map.get(name);
|
Object value = map.get(name);
|
||||||
|
@ -407,6 +440,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
if (value instanceof Float) {
|
if (value instanceof Float) {
|
||||||
return ((Float)value).floatValue();
|
return ((Float)value).floatValue();
|
||||||
}
|
}
|
||||||
|
if (value instanceof UTF8Buffer) {
|
||||||
|
return Float.valueOf(value.toString()).floatValue();
|
||||||
|
}
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
return Float.valueOf(value.toString()).floatValue();
|
return Float.valueOf(value.toString()).floatValue();
|
||||||
} else {
|
} else {
|
||||||
|
@ -424,6 +460,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* some internal error.
|
* some internal error.
|
||||||
* @throws MessageFormatException if this type conversion is invalid.
|
* @throws MessageFormatException if this type conversion is invalid.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getString(String name) throws JMSException {
|
public String getString(String name) throws JMSException {
|
||||||
initializeReading();
|
initializeReading();
|
||||||
Object value = map.get(name);
|
Object value = map.get(name);
|
||||||
|
@ -447,6 +484,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* some internal error.
|
* some internal error.
|
||||||
* @throws MessageFormatException if this type conversion is invalid.
|
* @throws MessageFormatException if this type conversion is invalid.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public byte[] getBytes(String name) throws JMSException {
|
public byte[] getBytes(String name) throws JMSException {
|
||||||
initializeReading();
|
initializeReading();
|
||||||
Object value = map.get(name);
|
Object value = map.get(name);
|
||||||
|
@ -476,9 +514,15 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* @throws JMSException if the JMS provider fails to read the message due to
|
* @throws JMSException if the JMS provider fails to read the message due to
|
||||||
* some internal error.
|
* some internal error.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object getObject(String name) throws JMSException {
|
public Object getObject(String name) throws JMSException {
|
||||||
initializeReading();
|
initializeReading();
|
||||||
return map.get(name);
|
Object result = map.get(name);
|
||||||
|
if (result instanceof UTF8Buffer) {
|
||||||
|
result = result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -488,6 +532,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* @return an enumeration of all the names in this <CODE>MapMessage</CODE>
|
* @return an enumeration of all the names in this <CODE>MapMessage</CODE>
|
||||||
* @throws JMSException
|
* @throws JMSException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Enumeration<String> getMapNames() throws JMSException {
|
public Enumeration<String> getMapNames() throws JMSException {
|
||||||
initializeReading();
|
initializeReading();
|
||||||
return Collections.enumeration(map.keySet());
|
return Collections.enumeration(map.keySet());
|
||||||
|
@ -514,6 +559,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* empty string.
|
* empty string.
|
||||||
* @throws MessageNotWriteableException if the message is in read-only mode.
|
* @throws MessageNotWriteableException if the message is in read-only mode.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setBoolean(String name, boolean value) throws JMSException {
|
public void setBoolean(String name, boolean value) throws JMSException {
|
||||||
initializeWriting();
|
initializeWriting();
|
||||||
put(name, value ? Boolean.TRUE : Boolean.FALSE);
|
put(name, value ? Boolean.TRUE : Boolean.FALSE);
|
||||||
|
@ -530,6 +576,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* empty string.
|
* empty string.
|
||||||
* @throws MessageNotWriteableException if the message is in read-only mode.
|
* @throws MessageNotWriteableException if the message is in read-only mode.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setByte(String name, byte value) throws JMSException {
|
public void setByte(String name, byte value) throws JMSException {
|
||||||
initializeWriting();
|
initializeWriting();
|
||||||
put(name, Byte.valueOf(value));
|
put(name, Byte.valueOf(value));
|
||||||
|
@ -546,6 +593,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* empty string.
|
* empty string.
|
||||||
* @throws MessageNotWriteableException if the message is in read-only mode.
|
* @throws MessageNotWriteableException if the message is in read-only mode.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setShort(String name, short value) throws JMSException {
|
public void setShort(String name, short value) throws JMSException {
|
||||||
initializeWriting();
|
initializeWriting();
|
||||||
put(name, Short.valueOf(value));
|
put(name, Short.valueOf(value));
|
||||||
|
@ -562,6 +610,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* empty string.
|
* empty string.
|
||||||
* @throws MessageNotWriteableException if the message is in read-only mode.
|
* @throws MessageNotWriteableException if the message is in read-only mode.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setChar(String name, char value) throws JMSException {
|
public void setChar(String name, char value) throws JMSException {
|
||||||
initializeWriting();
|
initializeWriting();
|
||||||
put(name, Character.valueOf(value));
|
put(name, Character.valueOf(value));
|
||||||
|
@ -578,6 +627,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* empty string.
|
* empty string.
|
||||||
* @throws MessageNotWriteableException if the message is in read-only mode.
|
* @throws MessageNotWriteableException if the message is in read-only mode.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setInt(String name, int value) throws JMSException {
|
public void setInt(String name, int value) throws JMSException {
|
||||||
initializeWriting();
|
initializeWriting();
|
||||||
put(name, Integer.valueOf(value));
|
put(name, Integer.valueOf(value));
|
||||||
|
@ -594,6 +644,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* empty string.
|
* empty string.
|
||||||
* @throws MessageNotWriteableException if the message is in read-only mode.
|
* @throws MessageNotWriteableException if the message is in read-only mode.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setLong(String name, long value) throws JMSException {
|
public void setLong(String name, long value) throws JMSException {
|
||||||
initializeWriting();
|
initializeWriting();
|
||||||
put(name, Long.valueOf(value));
|
put(name, Long.valueOf(value));
|
||||||
|
@ -610,6 +661,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* empty string.
|
* empty string.
|
||||||
* @throws MessageNotWriteableException if the message is in read-only mode.
|
* @throws MessageNotWriteableException if the message is in read-only mode.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setFloat(String name, float value) throws JMSException {
|
public void setFloat(String name, float value) throws JMSException {
|
||||||
initializeWriting();
|
initializeWriting();
|
||||||
put(name, new Float(value));
|
put(name, new Float(value));
|
||||||
|
@ -626,6 +678,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* empty string.
|
* empty string.
|
||||||
* @throws MessageNotWriteableException if the message is in read-only mode.
|
* @throws MessageNotWriteableException if the message is in read-only mode.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setDouble(String name, double value) throws JMSException {
|
public void setDouble(String name, double value) throws JMSException {
|
||||||
initializeWriting();
|
initializeWriting();
|
||||||
put(name, new Double(value));
|
put(name, new Double(value));
|
||||||
|
@ -642,6 +695,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* empty string.
|
* empty string.
|
||||||
* @throws MessageNotWriteableException if the message is in read-only mode.
|
* @throws MessageNotWriteableException if the message is in read-only mode.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setString(String name, String value) throws JMSException {
|
public void setString(String name, String value) throws JMSException {
|
||||||
initializeWriting();
|
initializeWriting();
|
||||||
put(name, value);
|
put(name, value);
|
||||||
|
@ -660,6 +714,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* empty string.
|
* empty string.
|
||||||
* @throws MessageNotWriteableException if the message is in read-only mode.
|
* @throws MessageNotWriteableException if the message is in read-only mode.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setBytes(String name, byte[] value) throws JMSException {
|
public void setBytes(String name, byte[] value) throws JMSException {
|
||||||
initializeWriting();
|
initializeWriting();
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
@ -683,6 +738,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* empty string.
|
* empty string.
|
||||||
* @throws MessageNotWriteableException if the message is in read-only mode.
|
* @throws MessageNotWriteableException if the message is in read-only mode.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setBytes(String name, byte[] value, int offset, int length) throws JMSException {
|
public void setBytes(String name, byte[] value, int offset, int length) throws JMSException {
|
||||||
initializeWriting();
|
initializeWriting();
|
||||||
byte[] data = new byte[length];
|
byte[] data = new byte[length];
|
||||||
|
@ -706,6 +762,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* @throws MessageFormatException if the object is invalid.
|
* @throws MessageFormatException if the object is invalid.
|
||||||
* @throws MessageNotWriteableException if the message is in read-only mode.
|
* @throws MessageNotWriteableException if the message is in read-only mode.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setObject(String name, Object value) throws JMSException {
|
public void setObject(String name, Object value) throws JMSException {
|
||||||
initializeWriting();
|
initializeWriting();
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
@ -728,6 +785,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
* @throws JMSException if the JMS provider fails to determine if the item
|
* @throws JMSException if the JMS provider fails to determine if the item
|
||||||
* exists due to some internal error.
|
* exists due to some internal error.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean itemExists(String name) throws JMSException {
|
public boolean itemExists(String name) throws JMSException {
|
||||||
initializeReading();
|
initializeReading();
|
||||||
return map.containsKey(name);
|
return map.containsKey(name);
|
||||||
|
@ -748,6 +806,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
|
||||||
super.compress();
|
super.compress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + " ActiveMQMapMessage{ " + "theTable = " + map + " }";
|
return super.toString() + " ActiveMQMapMessage{ " + "theTable = " + map + " }";
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
|
|
||||||
protected transient Callback acknowledgeCallback;
|
protected transient Callback acknowledgeCallback;
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte getDataStructureType() {
|
public byte getDataStructureType() {
|
||||||
return DATA_STRUCTURE_TYPE;
|
return DATA_STRUCTURE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +92,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
return thisMsg != null && oMsg != null && oMsg.equals(thisMsg);
|
return thisMsg != null && oMsg != null && oMsg.equals(thisMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void acknowledge() throws JMSException {
|
public void acknowledge() throws JMSException {
|
||||||
if (acknowledgeCallback != null) {
|
if (acknowledgeCallback != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -109,6 +111,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
readOnlyBody = false;
|
readOnlyBody = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getJMSMessageID() {
|
public String getJMSMessageID() {
|
||||||
MessageId messageId = this.getMessageId();
|
MessageId messageId = this.getMessageId();
|
||||||
if (messageId == null) {
|
if (messageId == null) {
|
||||||
|
@ -124,6 +127,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
* @param value
|
* @param value
|
||||||
* @throws JMSException
|
* @throws JMSException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setJMSMessageID(String value) throws JMSException {
|
public void setJMSMessageID(String value) throws JMSException {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -160,30 +164,37 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public long getJMSTimestamp() {
|
public long getJMSTimestamp() {
|
||||||
return this.getTimestamp();
|
return this.getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setJMSTimestamp(long timestamp) {
|
public void setJMSTimestamp(long timestamp) {
|
||||||
this.setTimestamp(timestamp);
|
this.setTimestamp(timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getJMSCorrelationID() {
|
public String getJMSCorrelationID() {
|
||||||
return this.getCorrelationId();
|
return this.getCorrelationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setJMSCorrelationID(String correlationId) {
|
public void setJMSCorrelationID(String correlationId) {
|
||||||
this.setCorrelationId(correlationId);
|
this.setCorrelationId(correlationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
|
public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
|
||||||
return encodeString(this.getCorrelationId());
|
return encodeString(this.getCorrelationId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setJMSCorrelationIDAsBytes(byte[] correlationId) throws JMSException {
|
public void setJMSCorrelationIDAsBytes(byte[] correlationId) throws JMSException {
|
||||||
this.setCorrelationId(decodeString(correlationId));
|
this.setCorrelationId(decodeString(correlationId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getJMSXMimeType() {
|
public String getJMSXMimeType() {
|
||||||
return "jms/message";
|
return "jms/message";
|
||||||
}
|
}
|
||||||
|
@ -210,58 +221,72 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Destination getJMSReplyTo() {
|
public Destination getJMSReplyTo() {
|
||||||
return this.getReplyTo();
|
return this.getReplyTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setJMSReplyTo(Destination destination) throws JMSException {
|
public void setJMSReplyTo(Destination destination) throws JMSException {
|
||||||
this.setReplyTo(ActiveMQDestination.transform(destination));
|
this.setReplyTo(ActiveMQDestination.transform(destination));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Destination getJMSDestination() {
|
public Destination getJMSDestination() {
|
||||||
return this.getDestination();
|
return this.getDestination();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setJMSDestination(Destination destination) throws JMSException {
|
public void setJMSDestination(Destination destination) throws JMSException {
|
||||||
this.setDestination(ActiveMQDestination.transform(destination));
|
this.setDestination(ActiveMQDestination.transform(destination));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getJMSDeliveryMode() {
|
public int getJMSDeliveryMode() {
|
||||||
return this.isPersistent() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
|
return this.isPersistent() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setJMSDeliveryMode(int mode) {
|
public void setJMSDeliveryMode(int mode) {
|
||||||
this.setPersistent(mode == DeliveryMode.PERSISTENT);
|
this.setPersistent(mode == DeliveryMode.PERSISTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean getJMSRedelivered() {
|
public boolean getJMSRedelivered() {
|
||||||
return this.isRedelivered();
|
return this.isRedelivered();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setJMSRedelivered(boolean redelivered) {
|
public void setJMSRedelivered(boolean redelivered) {
|
||||||
this.setRedelivered(redelivered);
|
this.setRedelivered(redelivered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getJMSType() {
|
public String getJMSType() {
|
||||||
return this.getType();
|
return this.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setJMSType(String type) {
|
public void setJMSType(String type) {
|
||||||
this.setType(type);
|
this.setType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public long getJMSExpiration() {
|
public long getJMSExpiration() {
|
||||||
return this.getExpiration();
|
return this.getExpiration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setJMSExpiration(long expiration) {
|
public void setJMSExpiration(long expiration) {
|
||||||
this.setExpiration(expiration);
|
this.setExpiration(expiration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getJMSPriority() {
|
public int getJMSPriority() {
|
||||||
return this.getPriority();
|
return this.getPriority();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setJMSPriority(int priority) {
|
public void setJMSPriority(int priority) {
|
||||||
this.setPriority((byte) priority);
|
this.setPriority((byte) priority);
|
||||||
}
|
}
|
||||||
|
@ -272,6 +297,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
readOnlyProperties = false;
|
readOnlyProperties = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean propertyExists(String name) throws JMSException {
|
public boolean propertyExists(String name) throws JMSException {
|
||||||
try {
|
try {
|
||||||
return (this.getProperties().containsKey(name) || getObjectProperty(name)!= null);
|
return (this.getProperties().containsKey(name) || getObjectProperty(name)!= null);
|
||||||
|
@ -280,6 +306,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public Enumeration getPropertyNames() throws JMSException {
|
public Enumeration getPropertyNames() throws JMSException {
|
||||||
try {
|
try {
|
||||||
|
@ -312,6 +339,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
|
|
||||||
static {
|
static {
|
||||||
JMS_PROPERTY_SETERS.put("JMSXDeliveryCount", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSXDeliveryCount", new PropertySetter() {
|
||||||
|
@Override
|
||||||
public void set(Message message, Object value) throws MessageFormatException {
|
public void set(Message message, Object value) throws MessageFormatException {
|
||||||
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
|
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
|
@ -321,6 +349,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSXGroupID", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSXGroupID", new PropertySetter() {
|
||||||
|
@Override
|
||||||
public void set(Message message, Object value) throws MessageFormatException {
|
public void set(Message message, Object value) throws MessageFormatException {
|
||||||
String rc = (String) TypeConversionSupport.convert(value, String.class);
|
String rc = (String) TypeConversionSupport.convert(value, String.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
|
@ -330,6 +359,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSXGroupSeq", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSXGroupSeq", new PropertySetter() {
|
||||||
|
@Override
|
||||||
public void set(Message message, Object value) throws MessageFormatException {
|
public void set(Message message, Object value) throws MessageFormatException {
|
||||||
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
|
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
|
@ -339,6 +369,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSCorrelationID", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSCorrelationID", new PropertySetter() {
|
||||||
|
@Override
|
||||||
public void set(Message message, Object value) throws MessageFormatException {
|
public void set(Message message, Object value) throws MessageFormatException {
|
||||||
String rc = (String) TypeConversionSupport.convert(value, String.class);
|
String rc = (String) TypeConversionSupport.convert(value, String.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
|
@ -348,6 +379,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSDeliveryMode", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSDeliveryMode", new PropertySetter() {
|
||||||
|
@Override
|
||||||
public void set(Message message, Object value) throws MessageFormatException {
|
public void set(Message message, Object value) throws MessageFormatException {
|
||||||
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
|
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
|
@ -363,6 +395,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSExpiration", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSExpiration", new PropertySetter() {
|
||||||
|
@Override
|
||||||
public void set(Message message, Object value) throws MessageFormatException {
|
public void set(Message message, Object value) throws MessageFormatException {
|
||||||
Long rc = (Long) TypeConversionSupport.convert(value, Long.class);
|
Long rc = (Long) TypeConversionSupport.convert(value, Long.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
|
@ -372,6 +405,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSPriority", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSPriority", new PropertySetter() {
|
||||||
|
@Override
|
||||||
public void set(Message message, Object value) throws MessageFormatException {
|
public void set(Message message, Object value) throws MessageFormatException {
|
||||||
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
|
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
|
@ -381,6 +415,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSRedelivered", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSRedelivered", new PropertySetter() {
|
||||||
|
@Override
|
||||||
public void set(Message message, Object value) throws MessageFormatException {
|
public void set(Message message, Object value) throws MessageFormatException {
|
||||||
Boolean rc = (Boolean) TypeConversionSupport.convert(value, Boolean.class);
|
Boolean rc = (Boolean) TypeConversionSupport.convert(value, Boolean.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
|
@ -390,6 +425,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSReplyTo", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSReplyTo", new PropertySetter() {
|
||||||
|
@Override
|
||||||
public void set(Message message, Object value) throws MessageFormatException {
|
public void set(Message message, Object value) throws MessageFormatException {
|
||||||
ActiveMQDestination rc = (ActiveMQDestination) TypeConversionSupport.convert(value, ActiveMQDestination.class);
|
ActiveMQDestination rc = (ActiveMQDestination) TypeConversionSupport.convert(value, ActiveMQDestination.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
|
@ -399,6 +435,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSTimestamp", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSTimestamp", new PropertySetter() {
|
||||||
|
@Override
|
||||||
public void set(Message message, Object value) throws MessageFormatException {
|
public void set(Message message, Object value) throws MessageFormatException {
|
||||||
Long rc = (Long) TypeConversionSupport.convert(value, Long.class);
|
Long rc = (Long) TypeConversionSupport.convert(value, Long.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
|
@ -408,6 +445,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSType", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSType", new PropertySetter() {
|
||||||
|
@Override
|
||||||
public void set(Message message, Object value) throws MessageFormatException {
|
public void set(Message message, Object value) throws MessageFormatException {
|
||||||
String rc = (String) TypeConversionSupport.convert(value, String.class);
|
String rc = (String) TypeConversionSupport.convert(value, String.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
|
@ -418,6 +456,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setObjectProperty(String name, Object value) throws JMSException {
|
public void setObjectProperty(String name, Object value) throws JMSException {
|
||||||
setObjectProperty(name, value, true);
|
setObjectProperty(name, value, true);
|
||||||
}
|
}
|
||||||
|
@ -450,7 +489,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
for (Map.Entry<String, ?> entry : properties.entrySet()) {
|
for (Map.Entry<String, ?> entry : properties.entrySet()) {
|
||||||
// Lets use the object property method as we may contain standard
|
// Lets use the object property method as we may contain standard
|
||||||
// extension headers like JMSXGroupID
|
// extension headers like JMSXGroupID
|
||||||
setObjectProperty((String) entry.getKey(), entry.getValue());
|
setObjectProperty(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,6 +537,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getObjectProperty(String name) throws JMSException {
|
public Object getObjectProperty(String name) throws JMSException {
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
throw new NullPointerException("Property name cannot be null");
|
throw new NullPointerException("Property name cannot be null");
|
||||||
|
@ -508,6 +548,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
return expression.evaluate(this);
|
return expression.evaluate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean getBooleanProperty(String name) throws JMSException {
|
public boolean getBooleanProperty(String name) throws JMSException {
|
||||||
Object value = getObjectProperty(name);
|
Object value = getObjectProperty(name);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@ -520,6 +561,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
return rc.booleanValue();
|
return rc.booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte getByteProperty(String name) throws JMSException {
|
public byte getByteProperty(String name) throws JMSException {
|
||||||
Object value = getObjectProperty(name);
|
Object value = getObjectProperty(name);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@ -532,6 +574,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
return rc.byteValue();
|
return rc.byteValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public short getShortProperty(String name) throws JMSException {
|
public short getShortProperty(String name) throws JMSException {
|
||||||
Object value = getObjectProperty(name);
|
Object value = getObjectProperty(name);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@ -544,6 +587,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
return rc.shortValue();
|
return rc.shortValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getIntProperty(String name) throws JMSException {
|
public int getIntProperty(String name) throws JMSException {
|
||||||
Object value = getObjectProperty(name);
|
Object value = getObjectProperty(name);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@ -556,6 +600,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
return rc.intValue();
|
return rc.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public long getLongProperty(String name) throws JMSException {
|
public long getLongProperty(String name) throws JMSException {
|
||||||
Object value = getObjectProperty(name);
|
Object value = getObjectProperty(name);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@ -568,6 +613,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
return rc.longValue();
|
return rc.longValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float getFloatProperty(String name) throws JMSException {
|
public float getFloatProperty(String name) throws JMSException {
|
||||||
Object value = getObjectProperty(name);
|
Object value = getObjectProperty(name);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@ -580,6 +626,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
return rc.floatValue();
|
return rc.floatValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getDoubleProperty(String name) throws JMSException {
|
public double getDoubleProperty(String name) throws JMSException {
|
||||||
Object value = getObjectProperty(name);
|
Object value = getObjectProperty(name);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@ -592,6 +639,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
return rc.doubleValue();
|
return rc.doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getStringProperty(String name) throws JMSException {
|
public String getStringProperty(String name) throws JMSException {
|
||||||
Object value = null;
|
Object value = null;
|
||||||
if (name.equals("JMSXUserID")) {
|
if (name.equals("JMSXUserID")) {
|
||||||
|
@ -612,6 +660,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBooleanProperty(String name, boolean value) throws JMSException {
|
public void setBooleanProperty(String name, boolean value) throws JMSException {
|
||||||
setBooleanProperty(name, value, true);
|
setBooleanProperty(name, value, true);
|
||||||
}
|
}
|
||||||
|
@ -620,30 +669,37 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
setObjectProperty(name, Boolean.valueOf(value), checkReadOnly);
|
setObjectProperty(name, Boolean.valueOf(value), checkReadOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setByteProperty(String name, byte value) throws JMSException {
|
public void setByteProperty(String name, byte value) throws JMSException {
|
||||||
setObjectProperty(name, Byte.valueOf(value));
|
setObjectProperty(name, Byte.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setShortProperty(String name, short value) throws JMSException {
|
public void setShortProperty(String name, short value) throws JMSException {
|
||||||
setObjectProperty(name, Short.valueOf(value));
|
setObjectProperty(name, Short.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setIntProperty(String name, int value) throws JMSException {
|
public void setIntProperty(String name, int value) throws JMSException {
|
||||||
setObjectProperty(name, Integer.valueOf(value));
|
setObjectProperty(name, Integer.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setLongProperty(String name, long value) throws JMSException {
|
public void setLongProperty(String name, long value) throws JMSException {
|
||||||
setObjectProperty(name, Long.valueOf(value));
|
setObjectProperty(name, Long.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setFloatProperty(String name, float value) throws JMSException {
|
public void setFloatProperty(String name, float value) throws JMSException {
|
||||||
setObjectProperty(name, new Float(value));
|
setObjectProperty(name, new Float(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setDoubleProperty(String name, double value) throws JMSException {
|
public void setDoubleProperty(String name, double value) throws JMSException {
|
||||||
setObjectProperty(name, new Double(value));
|
setObjectProperty(name, new Double(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setStringProperty(String name, String value) throws JMSException {
|
public void setStringProperty(String name, String value) throws JMSException {
|
||||||
setObjectProperty(name, value);
|
setObjectProperty(name, value);
|
||||||
}
|
}
|
||||||
|
@ -676,6 +732,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
setReadOnlyProperties(true);
|
setReadOnlyProperties(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Response visit(CommandVisitor visitor) throws Exception {
|
public Response visit(CommandVisitor visitor) throws Exception {
|
||||||
return visitor.processMessage(this);
|
return visitor.processMessage(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.fusesource.hawtbuf.UTF8Buffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The fixed version of the UTF8 encoding function. Some older JVM's UTF8
|
* The fixed version of the UTF8 encoding function. Some older JVM's UTF8
|
||||||
* encoding function breaks when handling large strings.
|
* encoding function breaks when handling large strings.
|
||||||
|
@ -100,7 +102,7 @@ public final class MarshallingSupport {
|
||||||
public static void marshalPrimitiveList(List list, DataOutputStream out) throws IOException {
|
public static void marshalPrimitiveList(List list, DataOutputStream out) throws IOException {
|
||||||
out.writeInt(list.size());
|
out.writeInt(list.size());
|
||||||
for (Iterator iter = list.iterator(); iter.hasNext();) {
|
for (Iterator iter = list.iterator(); iter.hasNext();) {
|
||||||
Object element = (Object)iter.next();
|
Object element = iter.next();
|
||||||
marshalPrimitive(out, element);
|
marshalPrimitive(out, element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,12 +182,28 @@ public final class MarshallingSupport {
|
||||||
value = new byte[in.readInt()];
|
value = new byte[in.readInt()];
|
||||||
in.readFully((byte[])value);
|
in.readFully((byte[])value);
|
||||||
break;
|
break;
|
||||||
case STRING_TYPE:
|
case STRING_TYPE: {
|
||||||
|
if (true) {
|
||||||
|
int length = in.readUnsignedShort();
|
||||||
|
byte data[] = new byte[length];
|
||||||
|
in.readFully(data);
|
||||||
|
value = new UTF8Buffer(data);
|
||||||
|
} else {
|
||||||
value = in.readUTF();
|
value = in.readUTF();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BIG_STRING_TYPE:
|
}
|
||||||
|
case BIG_STRING_TYPE: {
|
||||||
|
if (true) {
|
||||||
|
int length = in.readInt();
|
||||||
|
byte data[] = new byte[length];
|
||||||
|
in.readFully(data);
|
||||||
|
value = new UTF8Buffer(data);
|
||||||
|
} else {
|
||||||
value = readUTF8(in);
|
value = readUTF8(in);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case MAP_TYPE:
|
case MAP_TYPE:
|
||||||
value = unmarshalPrimitiveMap(in);
|
value = unmarshalPrimitiveMap(in);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.activemq.command.ActiveMQDestination;
|
import org.apache.activemq.command.ActiveMQDestination;
|
||||||
|
import org.fusesource.hawtbuf.UTF8Buffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type conversion support for ActiveMQ.
|
* Type conversion support for ActiveMQ.
|
||||||
|
@ -37,21 +38,23 @@ public final class TypeConversionSupport {
|
||||||
};
|
};
|
||||||
|
|
||||||
private static class ConversionKey {
|
private static class ConversionKey {
|
||||||
final Class from;
|
final Class<?> from;
|
||||||
final Class to;
|
final Class<?> to;
|
||||||
final int hashCode;
|
final int hashCode;
|
||||||
|
|
||||||
public ConversionKey(Class from, Class to) {
|
public ConversionKey(Class<?> from, Class<?> to) {
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.to = to;
|
this.to = to;
|
||||||
this.hashCode = from.hashCode() ^ (to.hashCode() << 1);
|
this.hashCode = from.hashCode() ^ (to.hashCode() << 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
ConversionKey x = (ConversionKey)o;
|
ConversionKey x = (ConversionKey)o;
|
||||||
return x.from == from && x.to == to;
|
return x.from == from && x.to == to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
|
@ -64,6 +67,7 @@ public final class TypeConversionSupport {
|
||||||
private static final Map<ConversionKey, Converter> CONVERSION_MAP = new HashMap<ConversionKey, Converter>();
|
private static final Map<ConversionKey, Converter> CONVERSION_MAP = new HashMap<ConversionKey, Converter>();
|
||||||
static {
|
static {
|
||||||
Converter toStringConverter = new Converter() {
|
Converter toStringConverter = new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
@ -75,44 +79,53 @@ public final class TypeConversionSupport {
|
||||||
CONVERSION_MAP.put(new ConversionKey(Long.class, String.class), toStringConverter);
|
CONVERSION_MAP.put(new ConversionKey(Long.class, String.class), toStringConverter);
|
||||||
CONVERSION_MAP.put(new ConversionKey(Float.class, String.class), toStringConverter);
|
CONVERSION_MAP.put(new ConversionKey(Float.class, String.class), toStringConverter);
|
||||||
CONVERSION_MAP.put(new ConversionKey(Double.class, String.class), toStringConverter);
|
CONVERSION_MAP.put(new ConversionKey(Double.class, String.class), toStringConverter);
|
||||||
|
CONVERSION_MAP.put(new ConversionKey(UTF8Buffer.class, String.class), toStringConverter);
|
||||||
|
|
||||||
CONVERSION_MAP.put(new ConversionKey(String.class, Boolean.class), new Converter() {
|
CONVERSION_MAP.put(new ConversionKey(String.class, Boolean.class), new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return Boolean.valueOf((String)value);
|
return Boolean.valueOf((String)value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
CONVERSION_MAP.put(new ConversionKey(String.class, Byte.class), new Converter() {
|
CONVERSION_MAP.put(new ConversionKey(String.class, Byte.class), new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return Byte.valueOf((String)value);
|
return Byte.valueOf((String)value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
CONVERSION_MAP.put(new ConversionKey(String.class, Short.class), new Converter() {
|
CONVERSION_MAP.put(new ConversionKey(String.class, Short.class), new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return Short.valueOf((String)value);
|
return Short.valueOf((String)value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
CONVERSION_MAP.put(new ConversionKey(String.class, Integer.class), new Converter() {
|
CONVERSION_MAP.put(new ConversionKey(String.class, Integer.class), new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return Integer.valueOf((String)value);
|
return Integer.valueOf((String)value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
CONVERSION_MAP.put(new ConversionKey(String.class, Long.class), new Converter() {
|
CONVERSION_MAP.put(new ConversionKey(String.class, Long.class), new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return Long.valueOf((String)value);
|
return Long.valueOf((String)value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
CONVERSION_MAP.put(new ConversionKey(String.class, Float.class), new Converter() {
|
CONVERSION_MAP.put(new ConversionKey(String.class, Float.class), new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return Float.valueOf((String)value);
|
return Float.valueOf((String)value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
CONVERSION_MAP.put(new ConversionKey(String.class, Double.class), new Converter() {
|
CONVERSION_MAP.put(new ConversionKey(String.class, Double.class), new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return Double.valueOf((String)value);
|
return Double.valueOf((String)value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Converter longConverter = new Converter() {
|
Converter longConverter = new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return Long.valueOf(((Number)value).longValue());
|
return Long.valueOf(((Number)value).longValue());
|
||||||
}
|
}
|
||||||
|
@ -121,12 +134,14 @@ public final class TypeConversionSupport {
|
||||||
CONVERSION_MAP.put(new ConversionKey(Short.class, Long.class), longConverter);
|
CONVERSION_MAP.put(new ConversionKey(Short.class, Long.class), longConverter);
|
||||||
CONVERSION_MAP.put(new ConversionKey(Integer.class, Long.class), longConverter);
|
CONVERSION_MAP.put(new ConversionKey(Integer.class, Long.class), longConverter);
|
||||||
CONVERSION_MAP.put(new ConversionKey(Date.class, Long.class), new Converter() {
|
CONVERSION_MAP.put(new ConversionKey(Date.class, Long.class), new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return Long.valueOf(((Date)value).getTime());
|
return Long.valueOf(((Date)value).getTime());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Converter intConverter = new Converter() {
|
Converter intConverter = new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return Integer.valueOf(((Number)value).intValue());
|
return Integer.valueOf(((Number)value).intValue());
|
||||||
}
|
}
|
||||||
|
@ -135,22 +150,26 @@ public final class TypeConversionSupport {
|
||||||
CONVERSION_MAP.put(new ConversionKey(Short.class, Integer.class), intConverter);
|
CONVERSION_MAP.put(new ConversionKey(Short.class, Integer.class), intConverter);
|
||||||
|
|
||||||
CONVERSION_MAP.put(new ConversionKey(Byte.class, Short.class), new Converter() {
|
CONVERSION_MAP.put(new ConversionKey(Byte.class, Short.class), new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return Short.valueOf(((Number)value).shortValue());
|
return Short.valueOf(((Number)value).shortValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CONVERSION_MAP.put(new ConversionKey(Float.class, Double.class), new Converter() {
|
CONVERSION_MAP.put(new ConversionKey(Float.class, Double.class), new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return new Double(((Number)value).doubleValue());
|
return new Double(((Number)value).doubleValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
CONVERSION_MAP.put(new ConversionKey(String.class, ActiveMQDestination.class), new Converter() {
|
CONVERSION_MAP.put(new ConversionKey(String.class, ActiveMQDestination.class), new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
return ActiveMQDestination.createDestination((String)value, ActiveMQDestination.QUEUE_TYPE);
|
return ActiveMQDestination.createDestination((String)value, ActiveMQDestination.QUEUE_TYPE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
CONVERSION_MAP.put(new ConversionKey(String.class, URI.class), new Converter() {
|
CONVERSION_MAP.put(new ConversionKey(String.class, URI.class), new Converter() {
|
||||||
|
@Override
|
||||||
public Object convert(Object value) {
|
public Object convert(Object value) {
|
||||||
String text = value.toString();
|
String text = value.toString();
|
||||||
try {
|
try {
|
||||||
|
@ -165,7 +184,7 @@ public final class TypeConversionSupport {
|
||||||
private TypeConversionSupport() {
|
private TypeConversionSupport() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object convert(Object value, Class to) {
|
public static Object convert(Object value, Class<?> to) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
// lets avoid NullPointerException when converting to boolean for null values
|
// lets avoid NullPointerException when converting to boolean for null values
|
||||||
if (boolean.class.isAssignableFrom(to)) {
|
if (boolean.class.isAssignableFrom(to)) {
|
||||||
|
@ -189,7 +208,7 @@ public final class TypeConversionSupport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Converter lookupConverter(Class from, Class to) {
|
public static Converter lookupConverter(Class<?> from, Class<?> to) {
|
||||||
// use wrapped type for primitives
|
// use wrapped type for primitives
|
||||||
if (from.isPrimitive()) {
|
if (from.isPrimitive()) {
|
||||||
from = convertPrimitiveTypeToWrapperType(from);
|
from = convertPrimitiveTypeToWrapperType(from);
|
||||||
|
@ -230,5 +249,4 @@ public final class TypeConversionSupport {
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue