INT-2713 AMQP Content-Type Mapping

Adjusted DefaultAmqpHeaderMapper to recognize and convert Content-Type
to String if the incoming Content-Type headers is of type
org.springframework.http.MediaType.

INT-2713 polishing
This commit is contained in:
Oleg Zhurakousky
2012-08-15 10:38:32 -04:00
committed by Gary Russell
parent de5506daf3
commit 6528574c7e
4 changed files with 70 additions and 16 deletions

View File

@@ -26,7 +26,6 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.MessageHeaders;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -135,7 +134,7 @@ public abstract class AbstractHeaderMapper<T> implements RequestReplyHeaderMappe
public Map<String, Object> toHeadersFromReply(T source) {
return this.toHeaders(source, this.replyHeaderNames);
}
private void fromHeaders(MessageHeaders headers, T target, List<String> headerPatterns){
try {
Map<String, Object> subset = new HashMap<String, Object>();
@@ -248,12 +247,16 @@ public abstract class AbstractHeaderMapper<T> implements RequestReplyHeaderMappe
}
if (!type.isAssignableFrom(value.getClass())) {
if (logger.isWarnEnabled()) {
logger.warn("skipping header '" + name + "' since it is not of expected type [" + type + "]");
logger.warn("skipping header '" + name + "' since it is not of expected type [" + type + "], it is [" +
value.getClass() + "]");
}
return null;
}
else {
return (V) value;
}
return (V) value;
}
private boolean containsElementIgnoreCase(List<String> headerNames, String name) {
for (String headerName : headerNames) {
if (headerName.equalsIgnoreCase(name)){
@@ -287,7 +290,7 @@ public abstract class AbstractHeaderMapper<T> implements RequestReplyHeaderMappe
protected List<String> getStandardRequestHeaderNames(){
return Collections.emptyList();
}
/**
* Returns the list of standard REPLY headers. Implementation provided by a subclass
*/