All pre-defined internal header names are now valid Java identifiers. Dot delimiters have been replaced by underscores, and hyphenated names are now camelCase. The SimpleHeaderEnricherParser uses Conventions.attributeToPropertyName(). The attributes are now legal for passing as JMS properties (INT-511).
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.integration.file;
|
||||
|
||||
import org.springframework.integration.core.MessageHeaders;
|
||||
|
||||
/**
|
||||
* Pre-defined header names to be used when storing or retrieving
|
||||
* File-related values to/from integration Message Headers.
|
||||
@@ -24,7 +26,7 @@ package org.springframework.integration.file;
|
||||
*/
|
||||
public abstract class FileHeaders {
|
||||
|
||||
public static final String PREFIX = "spring.integration.file.";
|
||||
public static final String PREFIX = MessageHeaders.PREFIX + "file_";
|
||||
|
||||
public static final String FILENAME = PREFIX + "name";
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.integration.jms;
|
||||
|
||||
import org.springframework.integration.core.MessageHeaders;
|
||||
|
||||
/**
|
||||
* Pre-defined names and prefixes to be used for setting and/or retrieving JMS
|
||||
* attributes from/to integration Message Headers.
|
||||
@@ -27,11 +29,11 @@ public abstract class JmsHeaders {
|
||||
/**
|
||||
* Prefix for any message header that should be passed for usage by the JMS transport.
|
||||
*/
|
||||
public static final String PREFIX = "spring.integration.jms.";
|
||||
public static final String PREFIX = MessageHeaders.PREFIX + "jms_";
|
||||
|
||||
public static final String CORRELATION_ID = PREFIX + "correlation-id";
|
||||
public static final String CORRELATION_ID = PREFIX + "correlationId";
|
||||
|
||||
public static final String REPLY_TO = PREFIX + "reply-to";
|
||||
public static final String REPLY_TO = PREFIX + "replyTo";
|
||||
|
||||
public static final String REDELIVERED = PREFIX + "redelivered";
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.integration.mail;
|
||||
|
||||
import org.springframework.integration.core.MessageHeaders;
|
||||
|
||||
/**
|
||||
* Pre-defined header names to be used for setting and/or retrieving Mail
|
||||
* Message attributes from/to integration Message Headers.
|
||||
@@ -24,7 +26,7 @@ package org.springframework.integration.mail;
|
||||
*/
|
||||
public abstract class MailHeaders {
|
||||
|
||||
public static final String PREFIX = "spring.integration.mail.";
|
||||
public static final String PREFIX = MessageHeaders.PREFIX + "mail_";
|
||||
|
||||
public static final String SUBJECT = PREFIX + "subject";
|
||||
|
||||
@@ -36,10 +38,10 @@ public abstract class MailHeaders {
|
||||
|
||||
public static final String FROM = PREFIX + "from";
|
||||
|
||||
public static final String REPLY_TO = PREFIX+ "reply-to";
|
||||
public static final String REPLY_TO = PREFIX+ "replyTo";
|
||||
|
||||
public static final String MULTIPART_MODE = PREFIX + "multipart-mode";
|
||||
public static final String MULTIPART_MODE = PREFIX + "multipartMode";
|
||||
|
||||
public static final String ATTACHMENT_FILENAME = PREFIX + "attachment-filename";
|
||||
public static final String ATTACHMENT_FILENAME = PREFIX + "attachmentFilename";
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
Web Service for the given URI, and the reply Message is sent to the 'celsiusChannel'. -->
|
||||
<chain input-channel="fahrenheitChannel" output-channel="celsiusChannel">
|
||||
<header-enricher>
|
||||
<header name="spring.integration.ws.soap-action" value="http://tempuri.org/FahrenheitToCelsius"/>
|
||||
<header name="springintegration_ws_soapAction" value="http://tempuri.org/FahrenheitToCelsius"/>
|
||||
</header-enricher>
|
||||
<ws:outbound-gateway uri="http://www.w3schools.com/webservices/tempconvert.asmx"/>
|
||||
</chain>
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.integration.ws;
|
||||
|
||||
import org.springframework.integration.core.MessageHeaders;
|
||||
|
||||
/**
|
||||
* Pre-defined header names to be used when storing or retrieving
|
||||
* Web Service properties to/from integration Message Headers.
|
||||
@@ -24,8 +26,8 @@ package org.springframework.integration.ws;
|
||||
*/
|
||||
public abstract class WebServiceHeaders {
|
||||
|
||||
public static final String PREFIX = "spring.integration.ws.";
|
||||
public static final String PREFIX = MessageHeaders.PREFIX + "ws_";
|
||||
|
||||
public static final String SOAP_ACTION = PREFIX + "soap-action";
|
||||
public static final String SOAP_ACTION = PREFIX + "soapAction";
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.ManagedMap;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.core.Conventions;
|
||||
import org.springframework.integration.transformer.HeaderEnricher;
|
||||
import org.springframework.integration.transformer.Transformer;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -84,6 +85,7 @@ public class SimpleHeaderEnricherParser extends AbstractTransformerParser {
|
||||
Node node = attributes.item(i);
|
||||
String name = node.getNodeName();
|
||||
if (this.isEligibleHeaderName(name)) {
|
||||
name = Conventions.attributeNameToPropertyName(name);
|
||||
Object value = (this.referenceAttributes.contains(name))
|
||||
? new RuntimeBeanReference(node.getNodeValue())
|
||||
: node.getNodeValue();
|
||||
|
||||
@@ -42,25 +42,25 @@ public final class MessageHeaders implements Map<String, Object>, Serializable {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(MessageHeaders.class);
|
||||
|
||||
public static final String PREFIX = "spring.integration.";
|
||||
public static final String PREFIX = "springintegration_";
|
||||
|
||||
public static final String ID = PREFIX + "id";
|
||||
|
||||
public static final String TIMESTAMP = PREFIX + "timestamp";
|
||||
|
||||
public static final String CORRELATION_ID = PREFIX + "correlation-id";
|
||||
public static final String CORRELATION_ID = PREFIX + "correlationId";
|
||||
|
||||
public static final String REPLY_CHANNEL = PREFIX + "reply-channel";
|
||||
public static final String REPLY_CHANNEL = PREFIX + "replyChannel";
|
||||
|
||||
public static final String ERROR_CHANNEL = PREFIX + "error-channel";
|
||||
public static final String ERROR_CHANNEL = PREFIX + "errorChannel";
|
||||
|
||||
public static final String EXPIRATION_DATE = PREFIX + "expiration-date";
|
||||
public static final String EXPIRATION_DATE = PREFIX + "expirationDate";
|
||||
|
||||
public static final String PRIORITY = PREFIX + "priority";
|
||||
|
||||
public static final String SEQUENCE_NUMBER = PREFIX + "sequence-number";
|
||||
public static final String SEQUENCE_NUMBER = PREFIX + "sequenceNumber";
|
||||
|
||||
public static final String SEQUENCE_SIZE = PREFIX + "sequence-size";
|
||||
public static final String SEQUENCE_SIZE = PREFIX + "sequenceSize";
|
||||
|
||||
|
||||
private final Map<String, Object> headers;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ChannelInterceptorTests {
|
||||
Message<?> result = channel.receive(0);
|
||||
assertNotNull(result);
|
||||
assertEquals("test", result.getPayload());
|
||||
assertEquals(1, result.getHeaders().get(PreSendReturnsMessageInterceptor.class.getName()));
|
||||
assertEquals(1, result.getHeaders().get(PreSendReturnsMessageInterceptor.class.getSimpleName()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -161,7 +161,7 @@ public class ChannelInterceptorTests {
|
||||
public Message<?> preSend(Message<?> message, MessageChannel channel) {
|
||||
assertNotNull(message);
|
||||
Message<?> reply = MessageBuilder.fromMessage(message)
|
||||
.setHeader(this.getClass().getName(), counter.incrementAndGet()).build();
|
||||
.setHeader(this.getClass().getSimpleName(), counter.incrementAndGet()).build();
|
||||
return reply;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user