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 683011f905..69b49f1256 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.JavaUtils; 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.messaging.MessageChannel; import org.springframework.scheduling.TaskScheduler; import org.springframework.util.Assert; @@ -83,6 +84,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; @@ -165,6 +172,18 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea 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; @@ -241,6 +260,8 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea 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) @@ -252,6 +273,7 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea .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 1ee53e1c72..fa210a44d1 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.core.task.TaskExecutor; 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.messaging.MessageChannel; import org.springframework.scheduling.TaskScheduler; import org.springframework.util.Assert; @@ -39,10 +40,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 abstract class BaseWsInboundGatewaySpec< 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 9bdafa5047..af47be5dd9 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 @@ import org.springframework.oxm.Unmarshaller; * 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 6e2994d77f..9622ac8853 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.junit.jupiter.api.Test; 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 @@ public class WsDslTests { @Test void simpleInbound() { - SimpleWebServiceInboundGateway gateway = Ws.simpleInboundGateway() - .extractPayload(false) - .get(); + DefaultSoapHeaderMapper testHeaderMapper = new DefaultSoapHeaderMapper(); + SimpleWebServiceInboundGateway gateway = + Ws.simpleInboundGateway() + .extractPayload(false) + .headerMapper(testHeaderMapper) + .errorChannel("myErrorChannel") + .get(); assertThat(TestUtils.getPropertyValue(gateway, "extractPayload", Boolean.class)).isFalse(); + assertThat(TestUtils.getPropertyValue(gateway, "headerMapper")).isSameAs(testHeaderMapper); + assertThat(TestUtils.getPropertyValue(gateway, "errorChannelName")).isEqualTo("myErrorChannel"); } @Test