diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/MessagingGatewaySpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/MessagingGatewaySpec.java index 23915e3265c..ed696e27f14 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/MessagingGatewaySpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/MessagingGatewaySpec.java @@ -35,7 +35,7 @@ public abstract class MessagingGatewaySpec, G extends MessagingGatewaySupport> extends IntegrationComponentSpec { - public MessagingGatewaySpec(@Nullable G gateway) { + public MessagingGatewaySpec(G gateway) { this.target = gateway; } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterFactoryBean.java b/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterFactoryBean.java index 35c86db47ec..47b9aa7c51e 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterFactoryBean.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterFactoryBean.java @@ -29,6 +29,7 @@ import org.springframework.integration.file.tail.ApacheCommonsFileTailingMessageProducer; import org.springframework.integration.file.tail.FileTailingMessageProducerSupport; import org.springframework.integration.file.tail.OSDelegatingFileTailingMessageProducer; +import org.springframework.integration.support.ErrorMessageStrategy; import org.springframework.lang.Nullable; import org.springframework.messaging.MessageChannel; import org.springframework.scheduling.TaskScheduler; @@ -84,6 +85,12 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea private ApplicationEventPublisher applicationEventPublisher; + private long sendTimeout; + + private boolean shouldTrack; + + private ErrorMessageStrategy errorMessageStrategy; + public void setNativeOptions(String nativeOptions) { if (StringUtils.hasText(nativeOptions)) { this.nativeOptions = nativeOptions; @@ -166,6 +173,18 @@ public void setPhase(int phase) { this.phase = phase; } + public void setSendTimeout(long sendTimeout) { + this.sendTimeout = sendTimeout; + } + + public void setShouldTrack(boolean shouldTrack) { + this.shouldTrack = shouldTrack; + } + + public void setErrorMessageStrategy(ErrorMessageStrategy errorMessageStrategy) { + this.errorMessageStrategy = errorMessageStrategy; + } + @Override public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { this.applicationEventPublisher = applicationEventPublisher; @@ -242,6 +261,8 @@ protected FileTailingMessageProducerSupport createInstance() { adapter.setOutputChannel(this.outputChannel); adapter.setErrorChannel(this.errorChannel); adapter.setBeanName(this.beanName); + adapter.setSendTimeout(this.sendTimeout); + adapter.setShouldTrack(this.shouldTrack); BeanFactory beanFactory = getBeanFactory(); JavaUtils.INSTANCE .acceptIfNotNull(this.taskExecutor, adapter::setTaskExecutor) @@ -253,6 +274,7 @@ protected FileTailingMessageProducerSupport createInstance() { .acceptIfNotNull(this.applicationEventPublisher, adapter::setApplicationEventPublisher) .acceptIfNotNull(this.outputChannelName, adapter::setOutputChannelName) .acceptIfNotNull(this.errorChannelName, adapter::setErrorChannelName) + .acceptIfNotNull(this.errorMessageStrategy, adapter::setErrorMessageStrategy) .acceptIfNotNull(beanFactory, adapter::setBeanFactory); adapter.afterPropertiesSet(); this.tailAdapter = adapter; diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/TailAdapterSpec.java b/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/TailAdapterSpec.java index 17c03d141c4..8b89122a7e2 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/TailAdapterSpec.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/TailAdapterSpec.java @@ -23,6 +23,7 @@ import org.springframework.integration.dsl.MessageProducerSpec; import org.springframework.integration.file.config.FileTailInboundChannelAdapterFactoryBean; import org.springframework.integration.file.tail.FileTailingMessageProducerSupport; +import org.springframework.integration.support.ErrorMessageStrategy; import org.springframework.lang.Nullable; import org.springframework.messaging.MessageChannel; import org.springframework.scheduling.TaskScheduler; @@ -40,12 +41,6 @@ public class TailAdapterSpec extends MessageProducerSpec the target {@link AbstractWebServiceInboundGateway} implementation type. * * @author Gary Russell + * @author Artem Bilan + * * @since 5.3 * */ @@ -35,10 +37,10 @@ public abstract class BaseWsInboundGatewaySpec< extends MessagingGatewaySpec { /** - * Construct an instance. + * Construct an instance based on the provided {@link AbstractWebServiceInboundGateway}. */ - protected BaseWsInboundGatewaySpec() { - super(null); + protected BaseWsInboundGatewaySpec(E gateway) { + super(gateway); } /** @@ -51,15 +53,4 @@ public S headerMapper(SoapHeaderMapper headerMapper) { return _this(); } - @Override - protected E doGet() { - return assemble(create()); - } - - protected abstract E create(); - - protected E assemble(E gateway) { - return gateway; - } - } diff --git a/spring-integration-ws/src/main/java/org/springframework/integration/ws/dsl/MarshallingWsInboundGatewaySpec.java b/spring-integration-ws/src/main/java/org/springframework/integration/ws/dsl/MarshallingWsInboundGatewaySpec.java index 9bdafa5047f..af47be5dd99 100644 --- a/spring-integration-ws/src/main/java/org/springframework/integration/ws/dsl/MarshallingWsInboundGatewaySpec.java +++ b/spring-integration-ws/src/main/java/org/springframework/integration/ws/dsl/MarshallingWsInboundGatewaySpec.java @@ -24,15 +24,18 @@ * The spec for a {@link MarshallingWebServiceInboundGateway}. * * @author Gary Russell + * @author Artem Bilan + * * @since 5.3 * */ -public class MarshallingWsInboundGatewaySpec extends BaseWsInboundGatewaySpec { +public class MarshallingWsInboundGatewaySpec + extends BaseWsInboundGatewaySpec { - protected Marshaller gatewayMarshaller; // NOSONAR - protected Unmarshaller gatewayUnmarshaller; // NOSONAR + protected MarshallingWsInboundGatewaySpec() { + super(new MarshallingWebServiceInboundGateway()); + } /** * Specify a marshaller to use. @@ -40,29 +43,22 @@ public class MarshallingWsInboundGatewaySpec extends BaseWsInboundGatewaySpec { +public class SimpleWsInboundGatewaySpec + extends BaseWsInboundGatewaySpec { - protected boolean extractPayload = true; // NOSONAR + protected SimpleWsInboundGatewaySpec() { + super(new SimpleWebServiceInboundGateway()); + } /** * Specify true to extract the payloadSource from the request or use * the entire request as the payload; default true. + * * @param extract true to extract. * @return the spec. */ public SimpleWsInboundGatewaySpec extractPayload(boolean extract) { - this.extractPayload = extract; + this.target.setExtractPayload(extract); return this; } - @Override - protected SimpleWebServiceInboundGateway create() { - SimpleWebServiceInboundGateway gateway = new SimpleWebServiceInboundGateway(); - gateway.setExtractPayload(this.extractPayload); - return gateway; - } - } diff --git a/spring-integration-ws/src/test/java/org/springframework/integration/ws/dsl/WsDslTests.java b/spring-integration-ws/src/test/java/org/springframework/integration/ws/dsl/WsDslTests.java index 9c2c8ce2462..269f9a7b88d 100644 --- a/spring-integration-ws/src/test/java/org/springframework/integration/ws/dsl/WsDslTests.java +++ b/spring-integration-ws/src/test/java/org/springframework/integration/ws/dsl/WsDslTests.java @@ -24,6 +24,7 @@ import org.springframework.expression.Expression; import org.springframework.expression.common.LiteralExpression; import org.springframework.integration.test.util.TestUtils; +import org.springframework.integration.ws.DefaultSoapHeaderMapper; import org.springframework.integration.ws.MarshallingWebServiceInboundGateway; import org.springframework.integration.ws.MarshallingWebServiceOutboundGateway; import org.springframework.integration.ws.SimpleWebServiceInboundGateway; @@ -71,10 +72,16 @@ void marshallingInbound() { @Test void simpleInbound() { - SimpleWebServiceInboundGateway gateway = Ws.simpleInboundGateway() - .extractPayload(false) - .getObject(); + DefaultSoapHeaderMapper testHeaderMapper = new DefaultSoapHeaderMapper(); + SimpleWebServiceInboundGateway gateway = + Ws.simpleInboundGateway() + .extractPayload(false) + .headerMapper(testHeaderMapper) + .errorChannel("myErrorChannel") + .getObject(); assertThat(TestUtils.getPropertyValue(gateway, "extractPayload", Boolean.class)).isFalse(); + assertThat(TestUtils.getPropertyValue(gateway, "headerMapper")).isSameAs(testHeaderMapper); + assertThat(TestUtils.getPropertyValue(gateway, "errorChannelName")).isEqualTo("myErrorChannel"); } @Test