diff --git a/activemq-client/pom.xml b/activemq-client/pom.xml
index 583d2e7220..1eda768591 100755
--- a/activemq-client/pom.xml
+++ b/activemq-client/pom.xml
@@ -46,6 +46,11 @@
org.apache.geronimo.specs
geronimo-jms_1.1_spec
+
+ org.fusesource.hawtbuf
+ hawtbuf
+ ${hawtbuf-version}
+
diff --git a/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java b/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java
index 1ae4e13f5f..23d5023033 100755
--- a/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java
+++ b/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java
@@ -41,6 +41,7 @@ import org.apache.activemq.util.ByteSequence;
import org.apache.activemq.util.JMSExceptionSupport;
import org.apache.activemq.util.MarshallingSupport;
import org.apache.activemq.wireformat.WireFormat;
+import org.fusesource.hawtbuf.UTF8Buffer;
/**
* A MapMessage
object is used to send a set of name-value pairs.
@@ -103,12 +104,13 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
protected transient Map map = new HashMap();
private Object readResolve() throws ObjectStreamException {
- if(this.map == null) {
+ if (this.map == null) {
this.map = new HashMap();
}
return this;
}
+ @Override
public Message copy() {
ActiveMQMapMessage copy = new ActiveMQMapMessage();
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.
+ @Override
public void beforeMarshall(WireFormat wireFormat) throws IOException {
super.beforeMarshall(wireFormat);
storeContent();
}
+ @Override
public void clearMarshalledState() throws JMSException {
super.clearMarshalledState();
map.clear();
@@ -175,10 +179,12 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
}
}
+ @Override
public byte getDataStructureType() {
return DATA_STRUCTURE_TYPE;
}
+ @Override
public String getJMSXMimeType() {
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.
*/
+ @Override
public void clearBody() throws JMSException {
super.clearBody();
map.clear();
@@ -205,6 +212,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
+ @Override
public boolean getBoolean(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
@@ -214,6 +222,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
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 {
@@ -230,6 +241,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
+ @Override
public byte getByte(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
@@ -239,6 +251,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
if (value instanceof Byte) {
return ((Byte)value).byteValue();
}
+ if (value instanceof UTF8Buffer) {
+ return Byte.valueOf(value.toString()).byteValue();
+ }
if (value instanceof String) {
return Byte.valueOf(value.toString()).byteValue();
} else {
@@ -255,6 +270,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
+ @Override
public short getShort(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
@@ -267,6 +283,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
if (value instanceof Byte) {
return ((Byte)value).shortValue();
}
+ if (value instanceof UTF8Buffer) {
+ return Short.valueOf(value.toString()).shortValue();
+ }
if (value instanceof String) {
return Short.valueOf(value.toString()).shortValue();
} else {
@@ -283,6 +302,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
+ @Override
public char getChar(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
@@ -305,6 +325,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
+ @Override
public int getInt(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
@@ -320,6 +341,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
if (value instanceof Byte) {
return ((Byte)value).intValue();
}
+ if (value instanceof UTF8Buffer) {
+ return Integer.valueOf(value.toString()).intValue();
+ }
if (value instanceof String) {
return Integer.valueOf(value.toString()).intValue();
} else {
@@ -336,6 +360,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
+ @Override
public long getLong(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
@@ -354,6 +379,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
if (value instanceof Byte) {
return ((Byte)value).longValue();
}
+ if (value instanceof UTF8Buffer) {
+ return Long.valueOf(value.toString()).longValue();
+ }
if (value instanceof String) {
return Long.valueOf(value.toString()).longValue();
} else {
@@ -370,6 +398,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
+ @Override
public float getFloat(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
@@ -379,6 +408,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
if (value instanceof Float) {
return ((Float)value).floatValue();
}
+ if (value instanceof UTF8Buffer) {
+ return Float.valueOf(value.toString()).floatValue();
+ }
if (value instanceof String) {
return Float.valueOf(value.toString()).floatValue();
} else {
@@ -395,6 +427,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
+ @Override
public double getDouble(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
@@ -407,6 +440,9 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
if (value instanceof Float) {
return ((Float)value).floatValue();
}
+ if (value instanceof UTF8Buffer) {
+ return Float.valueOf(value.toString()).floatValue();
+ }
if (value instanceof String) {
return Float.valueOf(value.toString()).floatValue();
} else {
@@ -424,6 +460,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
+ @Override
public String getString(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
@@ -447,6 +484,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
+ @Override
public byte[] getBytes(String name) throws JMSException {
initializeReading();
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
* some internal error.
*/
+ @Override
public Object getObject(String name) throws JMSException {
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 MapMessage
* @throws JMSException
*/
+ @Override
public Enumeration getMapNames() throws JMSException {
initializeReading();
return Collections.enumeration(map.keySet());
@@ -514,6 +559,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode.
*/
+ @Override
public void setBoolean(String name, boolean value) throws JMSException {
initializeWriting();
put(name, value ? Boolean.TRUE : Boolean.FALSE);
@@ -530,6 +576,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode.
*/
+ @Override
public void setByte(String name, byte value) throws JMSException {
initializeWriting();
put(name, Byte.valueOf(value));
@@ -546,6 +593,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode.
*/
+ @Override
public void setShort(String name, short value) throws JMSException {
initializeWriting();
put(name, Short.valueOf(value));
@@ -562,6 +610,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode.
*/
+ @Override
public void setChar(String name, char value) throws JMSException {
initializeWriting();
put(name, Character.valueOf(value));
@@ -578,6 +627,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode.
*/
+ @Override
public void setInt(String name, int value) throws JMSException {
initializeWriting();
put(name, Integer.valueOf(value));
@@ -594,6 +644,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode.
*/
+ @Override
public void setLong(String name, long value) throws JMSException {
initializeWriting();
put(name, Long.valueOf(value));
@@ -610,6 +661,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode.
*/
+ @Override
public void setFloat(String name, float value) throws JMSException {
initializeWriting();
put(name, new Float(value));
@@ -626,6 +678,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode.
*/
+ @Override
public void setDouble(String name, double value) throws JMSException {
initializeWriting();
put(name, new Double(value));
@@ -642,6 +695,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode.
*/
+ @Override
public void setString(String name, String value) throws JMSException {
initializeWriting();
put(name, value);
@@ -660,6 +714,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode.
*/
+ @Override
public void setBytes(String name, byte[] value) throws JMSException {
initializeWriting();
if (value != null) {
@@ -683,6 +738,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* empty string.
* @throws MessageNotWriteableException if the message is in read-only mode.
*/
+ @Override
public void setBytes(String name, byte[] value, int offset, int length) throws JMSException {
initializeWriting();
byte[] data = new byte[length];
@@ -706,6 +762,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
* @throws MessageFormatException if the object is invalid.
* @throws MessageNotWriteableException if the message is in read-only mode.
*/
+ @Override
public void setObject(String name, Object value) throws JMSException {
initializeWriting();
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
* exists due to some internal error.
*/
+ @Override
public boolean itemExists(String name) throws JMSException {
initializeReading();
return map.containsKey(name);
@@ -748,6 +806,7 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
super.compress();
}
+ @Override
public String toString() {
return super.toString() + " ActiveMQMapMessage{ " + "theTable = " + map + " }";
}
diff --git a/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMessage.java b/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
index 4ac309078a..75dac10480 100755
--- a/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
+++ b/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
@@ -50,6 +50,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
protected transient Callback acknowledgeCallback;
+ @Override
public byte getDataStructureType() {
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);
}
+ @Override
public void acknowledge() throws JMSException {
if (acknowledgeCallback != null) {
try {
@@ -109,6 +111,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
readOnlyBody = false;
}
+ @Override
public String getJMSMessageID() {
MessageId messageId = this.getMessageId();
if (messageId == null) {
@@ -124,6 +127,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
* @param value
* @throws JMSException
*/
+ @Override
public void setJMSMessageID(String value) throws JMSException {
if (value != null) {
try {
@@ -160,30 +164,37 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
}
+ @Override
public long getJMSTimestamp() {
return this.getTimestamp();
}
+ @Override
public void setJMSTimestamp(long timestamp) {
this.setTimestamp(timestamp);
}
+ @Override
public String getJMSCorrelationID() {
return this.getCorrelationId();
}
+ @Override
public void setJMSCorrelationID(String correlationId) {
this.setCorrelationId(correlationId);
}
+ @Override
public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
return encodeString(this.getCorrelationId());
}
+ @Override
public void setJMSCorrelationIDAsBytes(byte[] correlationId) throws JMSException {
this.setCorrelationId(decodeString(correlationId));
}
+ @Override
public String getJMSXMimeType() {
return "jms/message";
}
@@ -210,58 +221,72 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
}
+ @Override
public Destination getJMSReplyTo() {
return this.getReplyTo();
}
+ @Override
public void setJMSReplyTo(Destination destination) throws JMSException {
this.setReplyTo(ActiveMQDestination.transform(destination));
}
+ @Override
public Destination getJMSDestination() {
return this.getDestination();
}
+ @Override
public void setJMSDestination(Destination destination) throws JMSException {
this.setDestination(ActiveMQDestination.transform(destination));
}
+ @Override
public int getJMSDeliveryMode() {
return this.isPersistent() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
}
+ @Override
public void setJMSDeliveryMode(int mode) {
this.setPersistent(mode == DeliveryMode.PERSISTENT);
}
+ @Override
public boolean getJMSRedelivered() {
return this.isRedelivered();
}
+ @Override
public void setJMSRedelivered(boolean redelivered) {
this.setRedelivered(redelivered);
}
+ @Override
public String getJMSType() {
return this.getType();
}
+ @Override
public void setJMSType(String type) {
this.setType(type);
}
+ @Override
public long getJMSExpiration() {
return this.getExpiration();
}
+ @Override
public void setJMSExpiration(long expiration) {
this.setExpiration(expiration);
}
+ @Override
public int getJMSPriority() {
return this.getPriority();
}
+ @Override
public void setJMSPriority(int priority) {
this.setPriority((byte) priority);
}
@@ -272,6 +297,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
readOnlyProperties = false;
}
+ @Override
public boolean propertyExists(String name) throws JMSException {
try {
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")
public Enumeration getPropertyNames() throws JMSException {
try {
@@ -312,6 +339,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
static {
JMS_PROPERTY_SETERS.put("JMSXDeliveryCount", new PropertySetter() {
+ @Override
public void set(Message message, Object value) throws MessageFormatException {
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
if (rc == null) {
@@ -321,6 +349,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
});
JMS_PROPERTY_SETERS.put("JMSXGroupID", new PropertySetter() {
+ @Override
public void set(Message message, Object value) throws MessageFormatException {
String rc = (String) TypeConversionSupport.convert(value, String.class);
if (rc == null) {
@@ -330,6 +359,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
});
JMS_PROPERTY_SETERS.put("JMSXGroupSeq", new PropertySetter() {
+ @Override
public void set(Message message, Object value) throws MessageFormatException {
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
if (rc == null) {
@@ -339,6 +369,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
});
JMS_PROPERTY_SETERS.put("JMSCorrelationID", new PropertySetter() {
+ @Override
public void set(Message message, Object value) throws MessageFormatException {
String rc = (String) TypeConversionSupport.convert(value, String.class);
if (rc == null) {
@@ -348,6 +379,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
});
JMS_PROPERTY_SETERS.put("JMSDeliveryMode", new PropertySetter() {
+ @Override
public void set(Message message, Object value) throws MessageFormatException {
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
if (rc == null) {
@@ -363,6 +395,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
});
JMS_PROPERTY_SETERS.put("JMSExpiration", new PropertySetter() {
+ @Override
public void set(Message message, Object value) throws MessageFormatException {
Long rc = (Long) TypeConversionSupport.convert(value, Long.class);
if (rc == null) {
@@ -372,6 +405,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
});
JMS_PROPERTY_SETERS.put("JMSPriority", new PropertySetter() {
+ @Override
public void set(Message message, Object value) throws MessageFormatException {
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
if (rc == null) {
@@ -381,6 +415,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
});
JMS_PROPERTY_SETERS.put("JMSRedelivered", new PropertySetter() {
+ @Override
public void set(Message message, Object value) throws MessageFormatException {
Boolean rc = (Boolean) TypeConversionSupport.convert(value, Boolean.class);
if (rc == null) {
@@ -390,6 +425,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
});
JMS_PROPERTY_SETERS.put("JMSReplyTo", new PropertySetter() {
+ @Override
public void set(Message message, Object value) throws MessageFormatException {
ActiveMQDestination rc = (ActiveMQDestination) TypeConversionSupport.convert(value, ActiveMQDestination.class);
if (rc == null) {
@@ -399,6 +435,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
});
JMS_PROPERTY_SETERS.put("JMSTimestamp", new PropertySetter() {
+ @Override
public void set(Message message, Object value) throws MessageFormatException {
Long rc = (Long) TypeConversionSupport.convert(value, Long.class);
if (rc == null) {
@@ -408,6 +445,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
});
JMS_PROPERTY_SETERS.put("JMSType", new PropertySetter() {
+ @Override
public void set(Message message, Object value) throws MessageFormatException {
String rc = (String) TypeConversionSupport.convert(value, String.class);
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 {
setObjectProperty(name, value, true);
}
@@ -450,7 +489,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
for (Map.Entry entry : properties.entrySet()) {
// Lets use the object property method as we may contain standard
// extension headers like JMSXGroupID
- setObjectProperty((String) entry.getKey(), entry.getValue());
+ setObjectProperty(entry.getKey(), entry.getValue());
}
}
@@ -473,7 +512,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
}
- protected void checkValidScheduled(String name, Object value) throws MessageFormatException {
+ protected void checkValidScheduled(String name, Object value) throws MessageFormatException {
if (AMQ_SCHEDULED_DELAY.equals(name) || AMQ_SCHEDULED_PERIOD.equals(name) || AMQ_SCHEDULED_REPEAT.equals(name)) {
if (value instanceof Long == false && value instanceof Integer == false) {
throw new MessageFormatException(name + " should be long or int value");
@@ -484,7 +523,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
}
}
- protected Object convertScheduled(String name, Object value) throws MessageFormatException {
+ protected Object convertScheduled(String name, Object value) throws MessageFormatException {
Object result = value;
if (AMQ_SCHEDULED_DELAY.equals(name)){
result = TypeConversionSupport.convert(value, Long.class);
@@ -498,6 +537,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
return result;
}
+ @Override
public Object getObjectProperty(String name) throws JMSException {
if (name == 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);
}
+ @Override
public boolean getBooleanProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
if (value == null) {
@@ -520,6 +561,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
return rc.booleanValue();
}
+ @Override
public byte getByteProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
if (value == null) {
@@ -532,6 +574,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
return rc.byteValue();
}
+ @Override
public short getShortProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
if (value == null) {
@@ -544,6 +587,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
return rc.shortValue();
}
+ @Override
public int getIntProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
if (value == null) {
@@ -556,6 +600,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
return rc.intValue();
}
+ @Override
public long getLongProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
if (value == null) {
@@ -568,6 +613,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
return rc.longValue();
}
+ @Override
public float getFloatProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
if (value == null) {
@@ -580,6 +626,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
return rc.floatValue();
}
+ @Override
public double getDoubleProperty(String name) throws JMSException {
Object value = getObjectProperty(name);
if (value == null) {
@@ -592,6 +639,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
return rc.doubleValue();
}
+ @Override
public String getStringProperty(String name) throws JMSException {
Object value = null;
if (name.equals("JMSXUserID")) {
@@ -612,6 +660,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
return rc;
}
+ @Override
public void setBooleanProperty(String name, boolean value) throws JMSException {
setBooleanProperty(name, value, true);
}
@@ -620,30 +669,37 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
setObjectProperty(name, Boolean.valueOf(value), checkReadOnly);
}
+ @Override
public void setByteProperty(String name, byte value) throws JMSException {
setObjectProperty(name, Byte.valueOf(value));
}
+ @Override
public void setShortProperty(String name, short value) throws JMSException {
setObjectProperty(name, Short.valueOf(value));
}
+ @Override
public void setIntProperty(String name, int value) throws JMSException {
setObjectProperty(name, Integer.valueOf(value));
}
+ @Override
public void setLongProperty(String name, long value) throws JMSException {
setObjectProperty(name, Long.valueOf(value));
}
+ @Override
public void setFloatProperty(String name, float value) throws JMSException {
setObjectProperty(name, new Float(value));
}
+ @Override
public void setDoubleProperty(String name, double value) throws JMSException {
setObjectProperty(name, new Double(value));
}
+ @Override
public void setStringProperty(String name, String value) throws JMSException {
setObjectProperty(name, value);
}
@@ -676,6 +732,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
setReadOnlyProperties(true);
}
+ @Override
public Response visit(CommandVisitor visitor) throws Exception {
return visitor.processMessage(this);
}
diff --git a/activemq-client/src/main/java/org/apache/activemq/util/MarshallingSupport.java b/activemq-client/src/main/java/org/apache/activemq/util/MarshallingSupport.java
index 1e15e30c5d..1ccaebe67b 100755
--- a/activemq-client/src/main/java/org/apache/activemq/util/MarshallingSupport.java
+++ b/activemq-client/src/main/java/org/apache/activemq/util/MarshallingSupport.java
@@ -29,11 +29,13 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
+import org.fusesource.hawtbuf.UTF8Buffer;
+
/**
* The fixed version of the UTF8 encoding function. Some older JVM's UTF8
* encoding function breaks when handling large strings.
- *
- *
+ *
+ *
*/
public final class MarshallingSupport {
@@ -54,7 +56,7 @@ public final class MarshallingSupport {
private MarshallingSupport() {
}
-
+
public static void marshalPrimitiveMap(Map map, DataOutputStream out) throws IOException {
if (map == null) {
out.writeInt(-1);
@@ -100,7 +102,7 @@ public final class MarshallingSupport {
public static void marshalPrimitiveList(List list, DataOutputStream out) throws IOException {
out.writeInt(list.size());
for (Iterator iter = list.iterator(); iter.hasNext();) {
- Object element = (Object)iter.next();
+ Object element = iter.next();
marshalPrimitive(out, element);
}
}
@@ -180,12 +182,28 @@ public final class MarshallingSupport {
value = new byte[in.readInt()];
in.readFully((byte[])value);
break;
- case STRING_TYPE:
- value = in.readUTF();
+ 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();
+ }
break;
- case BIG_STRING_TYPE:
- value = readUTF8(in);
+ }
+ 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);
+ }
break;
+ }
case MAP_TYPE:
value = unmarshalPrimitiveMap(in);
break;
diff --git a/activemq-client/src/main/java/org/apache/activemq/util/TypeConversionSupport.java b/activemq-client/src/main/java/org/apache/activemq/util/TypeConversionSupport.java
index db9df29224..58c39526f3 100755
--- a/activemq-client/src/main/java/org/apache/activemq/util/TypeConversionSupport.java
+++ b/activemq-client/src/main/java/org/apache/activemq/util/TypeConversionSupport.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.activemq.command.ActiveMQDestination;
+import org.fusesource.hawtbuf.UTF8Buffer;
/**
* Type conversion support for ActiveMQ.
@@ -37,21 +38,23 @@ public final class TypeConversionSupport {
};
private static class ConversionKey {
- final Class from;
- final Class to;
+ final Class> from;
+ final Class> to;
final int hashCode;
- public ConversionKey(Class from, Class to) {
+ public ConversionKey(Class> from, Class> to) {
this.from = from;
this.to = to;
this.hashCode = from.hashCode() ^ (to.hashCode() << 1);
}
+ @Override
public boolean equals(Object o) {
ConversionKey x = (ConversionKey)o;
return x.from == from && x.to == to;
}
+ @Override
public int hashCode() {
return hashCode;
}
@@ -64,6 +67,7 @@ public final class TypeConversionSupport {
private static final Map CONVERSION_MAP = new HashMap();
static {
Converter toStringConverter = new Converter() {
+ @Override
public Object convert(Object value) {
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(Float.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() {
+ @Override
public Object convert(Object value) {
return Boolean.valueOf((String)value);
}
});
CONVERSION_MAP.put(new ConversionKey(String.class, Byte.class), new Converter() {
+ @Override
public Object convert(Object value) {
return Byte.valueOf((String)value);
}
});
CONVERSION_MAP.put(new ConversionKey(String.class, Short.class), new Converter() {
+ @Override
public Object convert(Object value) {
return Short.valueOf((String)value);
}
});
CONVERSION_MAP.put(new ConversionKey(String.class, Integer.class), new Converter() {
+ @Override
public Object convert(Object value) {
return Integer.valueOf((String)value);
}
});
CONVERSION_MAP.put(new ConversionKey(String.class, Long.class), new Converter() {
+ @Override
public Object convert(Object value) {
return Long.valueOf((String)value);
}
});
CONVERSION_MAP.put(new ConversionKey(String.class, Float.class), new Converter() {
+ @Override
public Object convert(Object value) {
return Float.valueOf((String)value);
}
});
CONVERSION_MAP.put(new ConversionKey(String.class, Double.class), new Converter() {
+ @Override
public Object convert(Object value) {
return Double.valueOf((String)value);
}
});
Converter longConverter = new Converter() {
+ @Override
public Object convert(Object value) {
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(Integer.class, Long.class), longConverter);
CONVERSION_MAP.put(new ConversionKey(Date.class, Long.class), new Converter() {
+ @Override
public Object convert(Object value) {
return Long.valueOf(((Date)value).getTime());
}
});
Converter intConverter = new Converter() {
+ @Override
public Object convert(Object value) {
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(Byte.class, Short.class), new Converter() {
+ @Override
public Object convert(Object value) {
return Short.valueOf(((Number)value).shortValue());
}
});
CONVERSION_MAP.put(new ConversionKey(Float.class, Double.class), new Converter() {
+ @Override
public Object convert(Object value) {
return new Double(((Number)value).doubleValue());
}
});
CONVERSION_MAP.put(new ConversionKey(String.class, ActiveMQDestination.class), new Converter() {
+ @Override
public Object convert(Object value) {
return ActiveMQDestination.createDestination((String)value, ActiveMQDestination.QUEUE_TYPE);
}
});
CONVERSION_MAP.put(new ConversionKey(String.class, URI.class), new Converter() {
+ @Override
public Object convert(Object value) {
String text = value.toString();
try {
@@ -165,7 +184,7 @@ public final class TypeConversionSupport {
private TypeConversionSupport() {
}
- public static Object convert(Object value, Class to) {
+ public static Object convert(Object value, Class> to) {
if (value == null) {
// lets avoid NullPointerException when converting to boolean for null values
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
if (from.isPrimitive()) {
from = convertPrimitiveTypeToWrapperType(from);
@@ -230,5 +249,4 @@ public final class TypeConversionSupport {
}
return rc;
}
-
}