mirror of https://github.com/apache/activemq.git
- Fix for https://issues.apache.org/activemq/browse/AMQ-1576 (behavior is that if a jms property is null, it will not be converted, but will still be added to the default list of properties)
- Fix a spelling typo git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@629060 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8768a04e63
commit
13af1e36fb
|
@ -181,27 +181,27 @@ public final class ActiveMQMessageTransformation {
|
||||||
* message to the specified message
|
* message to the specified message
|
||||||
*
|
*
|
||||||
* @param fromMessage the message to take the properties from
|
* @param fromMessage the message to take the properties from
|
||||||
* @param toMesage the message to add the properties to
|
* @param toMessage the message to add the properties to
|
||||||
* @throws JMSException
|
* @throws JMSException
|
||||||
*/
|
*/
|
||||||
public static void copyProperties(Message fromMessage, Message toMesage) throws JMSException {
|
public static void copyProperties(Message fromMessage, Message toMessage) throws JMSException {
|
||||||
toMesage.setJMSMessageID(fromMessage.getJMSMessageID());
|
toMessage.setJMSMessageID(fromMessage.getJMSMessageID());
|
||||||
toMesage.setJMSCorrelationID(fromMessage.getJMSCorrelationID());
|
toMessage.setJMSCorrelationID(fromMessage.getJMSCorrelationID());
|
||||||
toMesage.setJMSReplyTo(transformDestination(fromMessage.getJMSReplyTo()));
|
toMessage.setJMSReplyTo(transformDestination(fromMessage.getJMSReplyTo()));
|
||||||
toMesage.setJMSDestination(transformDestination(fromMessage.getJMSDestination()));
|
toMessage.setJMSDestination(transformDestination(fromMessage.getJMSDestination()));
|
||||||
toMesage.setJMSDeliveryMode(fromMessage.getJMSDeliveryMode());
|
toMessage.setJMSDeliveryMode(fromMessage.getJMSDeliveryMode());
|
||||||
toMesage.setJMSRedelivered(fromMessage.getJMSRedelivered());
|
toMessage.setJMSRedelivered(fromMessage.getJMSRedelivered());
|
||||||
toMesage.setJMSType(fromMessage.getJMSType());
|
toMessage.setJMSType(fromMessage.getJMSType());
|
||||||
toMesage.setJMSExpiration(fromMessage.getJMSExpiration());
|
toMessage.setJMSExpiration(fromMessage.getJMSExpiration());
|
||||||
toMesage.setJMSPriority(fromMessage.getJMSPriority());
|
toMessage.setJMSPriority(fromMessage.getJMSPriority());
|
||||||
toMesage.setJMSTimestamp(fromMessage.getJMSTimestamp());
|
toMessage.setJMSTimestamp(fromMessage.getJMSTimestamp());
|
||||||
|
|
||||||
Enumeration propertyNames = fromMessage.getPropertyNames();
|
Enumeration propertyNames = fromMessage.getPropertyNames();
|
||||||
|
|
||||||
while (propertyNames.hasMoreElements()) {
|
while (propertyNames.hasMoreElements()) {
|
||||||
String name = propertyNames.nextElement().toString();
|
String name = propertyNames.nextElement().toString();
|
||||||
Object obj = fromMessage.getObjectProperty(name);
|
Object obj = fromMessage.getObjectProperty(name);
|
||||||
toMesage.setObjectProperty(name, obj);
|
toMessage.setObjectProperty(name, obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ import org.apache.activemq.util.JMSExceptionSupport;
|
||||||
import org.apache.activemq.util.TypeConversionSupport;
|
import org.apache.activemq.util.TypeConversionSupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @openwire:marshaller code="23"
|
|
||||||
* @version $Revision:$
|
* @version $Revision:$
|
||||||
|
* @openwire:marshaller code="23"
|
||||||
*/
|
*/
|
||||||
public class ActiveMQMessage extends Message implements org.apache.activemq.Message {
|
public class ActiveMQMessage extends Message implements org.apache.activemq.Message {
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveMQMessage msg = (ActiveMQMessage)o;
|
ActiveMQMessage msg = (ActiveMQMessage) o;
|
||||||
MessageId oMsg = msg.getMessageId();
|
MessageId oMsg = msg.getMessageId();
|
||||||
MessageId thisMsg = this.getMessageId();
|
MessageId thisMsg = this.getMessageId();
|
||||||
return thisMsg != null && oMsg != null && oMsg.equals(thisMsg);
|
return thisMsg != null && oMsg != null && oMsg.equals(thisMsg);
|
||||||
|
@ -259,7 +259,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJMSPriority(int priority) {
|
public void setJMSPriority(int priority) {
|
||||||
this.setPriority((byte)priority);
|
this.setPriority((byte) priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearProperties() {
|
public void clearProperties() {
|
||||||
|
@ -284,13 +284,14 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PropertySetter {
|
interface PropertySetter {
|
||||||
|
|
||||||
void set(Message message, Object value) throws MessageFormatException;
|
void set(Message message, Object value) throws MessageFormatException;
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
JMS_PROPERTY_SETERS.put("JMSXDeliveryCount", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSXDeliveryCount", new PropertySetter() {
|
||||||
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) {
|
||||||
throw new MessageFormatException("Property JMSXDeliveryCount cannot be set from a " + value.getClass().getName() + ".");
|
throw new MessageFormatException("Property JMSXDeliveryCount cannot be set from a " + value.getClass().getName() + ".");
|
||||||
}
|
}
|
||||||
|
@ -299,7 +300,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() {
|
||||||
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) {
|
||||||
throw new MessageFormatException("Property JMSXGroupID cannot be set from a " + value.getClass().getName() + ".");
|
throw new MessageFormatException("Property JMSXGroupID cannot be set from a " + value.getClass().getName() + ".");
|
||||||
}
|
}
|
||||||
|
@ -308,7 +309,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() {
|
||||||
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) {
|
||||||
throw new MessageFormatException("Property JMSXGroupSeq cannot be set from a " + value.getClass().getName() + ".");
|
throw new MessageFormatException("Property JMSXGroupSeq cannot be set from a " + value.getClass().getName() + ".");
|
||||||
}
|
}
|
||||||
|
@ -317,65 +318,65 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSCorrelationID", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSCorrelationID", new PropertySetter() {
|
||||||
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) {
|
||||||
throw new MessageFormatException("Property JMSCorrelationID cannot be set from a " + value.getClass().getName() + ".");
|
throw new MessageFormatException("Property JMSCorrelationID cannot be set from a " + value.getClass().getName() + ".");
|
||||||
}
|
}
|
||||||
((ActiveMQMessage)message).setJMSCorrelationID(rc);
|
((ActiveMQMessage) message).setJMSCorrelationID(rc);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSExpiration", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSExpiration", new PropertySetter() {
|
||||||
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) {
|
||||||
throw new MessageFormatException("Property JMSExpiration cannot be set from a " + value.getClass().getName() + ".");
|
throw new MessageFormatException("Property JMSExpiration cannot be set from a " + value.getClass().getName() + ".");
|
||||||
}
|
}
|
||||||
((ActiveMQMessage)message).setJMSExpiration(rc.longValue());
|
((ActiveMQMessage) message).setJMSExpiration(rc.longValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSPriority", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSPriority", new PropertySetter() {
|
||||||
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) {
|
||||||
throw new MessageFormatException("Property JMSPriority cannot be set from a " + value.getClass().getName() + ".");
|
throw new MessageFormatException("Property JMSPriority cannot be set from a " + value.getClass().getName() + ".");
|
||||||
}
|
}
|
||||||
((ActiveMQMessage)message).setJMSPriority(rc.intValue());
|
((ActiveMQMessage) message).setJMSPriority(rc.intValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSRedelivered", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSRedelivered", new PropertySetter() {
|
||||||
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) {
|
||||||
throw new MessageFormatException("Property JMSRedelivered cannot be set from a " + value.getClass().getName() + ".");
|
throw new MessageFormatException("Property JMSRedelivered cannot be set from a " + value.getClass().getName() + ".");
|
||||||
}
|
}
|
||||||
((ActiveMQMessage)message).setJMSRedelivered(rc.booleanValue());
|
((ActiveMQMessage) message).setJMSRedelivered(rc.booleanValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSReplyTo", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSReplyTo", new PropertySetter() {
|
||||||
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) {
|
||||||
throw new MessageFormatException("Property JMSReplyTo cannot be set from a " + value.getClass().getName() + ".");
|
throw new MessageFormatException("Property JMSReplyTo cannot be set from a " + value.getClass().getName() + ".");
|
||||||
}
|
}
|
||||||
((ActiveMQMessage)message).setReplyTo(rc);
|
((ActiveMQMessage) message).setReplyTo(rc);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSTimestamp", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSTimestamp", new PropertySetter() {
|
||||||
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) {
|
||||||
throw new MessageFormatException("Property JMSTimestamp cannot be set from a " + value.getClass().getName() + ".");
|
throw new MessageFormatException("Property JMSTimestamp cannot be set from a " + value.getClass().getName() + ".");
|
||||||
}
|
}
|
||||||
((ActiveMQMessage)message).setJMSTimestamp(rc.longValue());
|
((ActiveMQMessage) message).setJMSTimestamp(rc.longValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMS_PROPERTY_SETERS.put("JMSType", new PropertySetter() {
|
JMS_PROPERTY_SETERS.put("JMSType", new PropertySetter() {
|
||||||
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) {
|
||||||
throw new MessageFormatException("Property JMSType cannot be set from a " + value.getClass().getName() + ".");
|
throw new MessageFormatException("Property JMSType cannot be set from a " + value.getClass().getName() + ".");
|
||||||
}
|
}
|
||||||
((ActiveMQMessage)message).setJMSType(rc);
|
((ActiveMQMessage) message).setJMSType(rc);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -396,7 +397,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
checkValidObject(value);
|
checkValidObject(value);
|
||||||
PropertySetter setter = JMS_PROPERTY_SETERS.get(name);
|
PropertySetter setter = JMS_PROPERTY_SETERS.get(name);
|
||||||
|
|
||||||
if (setter != null) {
|
if (setter != null && value != null) {
|
||||||
setter.set(this, value);
|
setter.set(this, value);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
@ -409,11 +410,11 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
|
|
||||||
public void setProperties(Map properties) throws JMSException {
|
public void setProperties(Map properties) throws JMSException {
|
||||||
for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) {
|
for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) {
|
||||||
Map.Entry entry = (Map.Entry)iter.next();
|
Map.Entry entry = (Map.Entry) iter.next();
|
||||||
|
|
||||||
// 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((String) entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,7 +452,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Boolean rc = (Boolean)TypeConversionSupport.convert(value, Boolean.class);
|
Boolean rc = (Boolean) TypeConversionSupport.convert(value, Boolean.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a boolean");
|
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a boolean");
|
||||||
}
|
}
|
||||||
|
@ -463,7 +464,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NumberFormatException("property " + name + " was null");
|
throw new NumberFormatException("property " + name + " was null");
|
||||||
}
|
}
|
||||||
Byte rc = (Byte)TypeConversionSupport.convert(value, Byte.class);
|
Byte rc = (Byte) TypeConversionSupport.convert(value, Byte.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a byte");
|
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a byte");
|
||||||
}
|
}
|
||||||
|
@ -475,7 +476,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NumberFormatException("property " + name + " was null");
|
throw new NumberFormatException("property " + name + " was null");
|
||||||
}
|
}
|
||||||
Short rc = (Short)TypeConversionSupport.convert(value, Short.class);
|
Short rc = (Short) TypeConversionSupport.convert(value, Short.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a short");
|
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a short");
|
||||||
}
|
}
|
||||||
|
@ -487,7 +488,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NumberFormatException("property " + name + " was null");
|
throw new NumberFormatException("property " + name + " was null");
|
||||||
}
|
}
|
||||||
Integer rc = (Integer)TypeConversionSupport.convert(value, Integer.class);
|
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as an integer");
|
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as an integer");
|
||||||
}
|
}
|
||||||
|
@ -499,7 +500,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NumberFormatException("property " + name + " was null");
|
throw new NumberFormatException("property " + name + " was null");
|
||||||
}
|
}
|
||||||
Long rc = (Long)TypeConversionSupport.convert(value, Long.class);
|
Long rc = (Long) TypeConversionSupport.convert(value, Long.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a long");
|
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a long");
|
||||||
}
|
}
|
||||||
|
@ -511,7 +512,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NullPointerException("property " + name + " was null");
|
throw new NullPointerException("property " + name + " was null");
|
||||||
}
|
}
|
||||||
Float rc = (Float)TypeConversionSupport.convert(value, Float.class);
|
Float rc = (Float) TypeConversionSupport.convert(value, Float.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a float");
|
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a float");
|
||||||
}
|
}
|
||||||
|
@ -523,7 +524,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NullPointerException("property " + name + " was null");
|
throw new NullPointerException("property " + name + " was null");
|
||||||
}
|
}
|
||||||
Double rc = (Double)TypeConversionSupport.convert(value, Double.class);
|
Double rc = (Double) TypeConversionSupport.convert(value, Double.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a double");
|
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a double");
|
||||||
}
|
}
|
||||||
|
@ -540,7 +541,7 @@ public class ActiveMQMessage extends Message implements org.apache.activemq.Mess
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String rc = (String)TypeConversionSupport.convert(value, String.class);
|
String rc = (String) TypeConversionSupport.convert(value, String.class);
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a String");
|
throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a String");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue