Skip to content

Commit 422f651

Browse files
garyrussellartembilan
authored andcommitted
DSL: Polishing AMQP ICA Spec
Also add `messageHeaders()` to `MessageSourceSpec`.
1 parent b5ec98f commit 422f651

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

spring-integration-amqp/src/main/java/org/springframework/integration/amqp/dsl/AmqpInboundPolledChannelAdapterSpec.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ public AmqpInboundPolledChannelAdapterSpec transacted(boolean transacted) {
5050
return this;
5151
}
5252

53-
public AmqpInboundPolledChannelAdapterSpec setPropertiesConverter(MessagePropertiesConverter propertiesConverter) {
53+
public AmqpInboundPolledChannelAdapterSpec propertiesConverter(MessagePropertiesConverter propertiesConverter) {
5454
this.target.setPropertiesConverter(propertiesConverter);
5555
return this;
5656
}
5757

58-
public AmqpInboundPolledChannelAdapterSpec setHeaderMapper(AmqpHeaderMapper headerMapper) {
58+
public AmqpInboundPolledChannelAdapterSpec headerMapper(AmqpHeaderMapper headerMapper) {
5959
this.target.setHeaderMapper(headerMapper);
6060
return this;
6161
}
6262

63-
public AmqpInboundPolledChannelAdapterSpec setMessageConverter(MessageConverter messageConverter) {
63+
public AmqpInboundPolledChannelAdapterSpec messageConverter(MessageConverter messageConverter) {
6464
this.target.setMessageConverter(messageConverter);
6565
return this;
6666
}

spring-integration-core/src/main/java/org/springframework/integration/dsl/MessageSourceSpec.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 the original author or authors.
2+
* Copyright 2016-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,12 @@
1616

1717
package org.springframework.integration.dsl;
1818

19+
import java.util.Map;
20+
21+
import org.springframework.expression.Expression;
1922
import org.springframework.integration.core.MessageSource;
23+
import org.springframework.integration.endpoint.AbstractMessageSource;
24+
import org.springframework.util.Assert;
2025

2126
/**
2227
* An {@link IntegrationComponentSpec} for {@link MessageSource}s.
@@ -25,9 +30,26 @@
2530
* @param <H> the target {@link MessageSource} implementation type.
2631
*
2732
* @author Artem Bilan
33+
* @author Gary Russell
2834
*
2935
* @since 5.0
3036
*/
3137
public abstract class MessageSourceSpec<S extends MessageSourceSpec<S, H>, H extends MessageSource<?>>
3238
extends IntegrationComponentSpec<S, H> {
39+
40+
/**
41+
* Expressions with which to enhance headers.
42+
* Only applies to subclasses of {@link AbstractMessageSource}.
43+
* @param headerExpressions the header expressions.
44+
* @return the spec.
45+
* @since 5.0.1
46+
*/
47+
public S messageHeaders(Map<String, Expression> headerExpressions) {
48+
Assert.state(this.target instanceof AbstractMessageSource,
49+
() -> "'MessageSource' must be an instance of 'AbstractMessageSource', not "
50+
+ this.target.getClass());
51+
((AbstractMessageSource<?>) this.target).setHeaderExpressions(headerExpressions);
52+
return _this();
53+
}
54+
3355
}

0 commit comments

Comments
 (0)