diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 3fc7178295..e4bf7284c3 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -147,6 +147,7 @@ Hopper-SR1 0.19.0.RELEASE 4.3.0.M1 + 1.1.2.RELEASE 1.2.5.RELEASE 1.1.5.RELEASE 1.2.0.RELEASE @@ -2064,6 +2065,11 @@ + + org.springframework.integration + spring-integration-java-dsl + ${spring-integration-java-dsl.version} + org.springframework.mobile spring-mobile-device diff --git a/spring-boot-samples/spring-boot-sample-integration/pom.xml b/spring-boot-samples/spring-boot-sample-integration/pom.xml index 46d5a5a792..37f9d1a99d 100644 --- a/spring-boot-samples/spring-boot-sample-integration/pom.xml +++ b/spring-boot-samples/spring-boot-sample-integration/pom.xml @@ -27,6 +27,10 @@ org.springframework.boot spring-boot-starter-actuator + + org.springframework.integration + spring-integration-file + org.springframework.integration spring-integration-jmx diff --git a/spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/HelloWorldService.java b/spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/HelloWorldService.java index f904d07dab..e68197c39a 100644 --- a/spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/HelloWorldService.java +++ b/spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/HelloWorldService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +16,16 @@ package sample.integration; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; -@Component +@Service public class HelloWorldService { - @Autowired - private ServiceProperties configuration; + private final ServiceProperties configuration; + + public HelloWorldService(ServiceProperties configuration) { + this.configuration = configuration; + } public String getHelloMessage(String name) { return this.configuration.getGreeting() + " " + name; diff --git a/spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/SampleEndpoint.java b/spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/SampleEndpoint.java index 852d9797b6..a478666b68 100644 --- a/spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/SampleEndpoint.java +++ b/spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/SampleEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ package sample.integration; import java.io.File; import java.io.FileInputStream; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.integration.annotation.MessageEndpoint; import org.springframework.integration.annotation.ServiceActivator; import org.springframework.util.StreamUtils; @@ -27,8 +26,11 @@ import org.springframework.util.StreamUtils; @MessageEndpoint public class SampleEndpoint { - @Autowired - private HelloWorldService helloWorldService; + private final HelloWorldService helloWorldService; + + public SampleEndpoint(HelloWorldService helloWorldService) { + this.helloWorldService = helloWorldService; + } @ServiceActivator public String hello(File input) throws Exception { diff --git a/spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/SampleIntegrationApplication.java b/spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/SampleIntegrationApplication.java index 96fec47923..a893f386d5 100644 --- a/spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/SampleIntegrationApplication.java +++ b/spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/SampleIntegrationApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,18 +16,69 @@ package sample.integration; +import java.io.File; + import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.ImportResource; +import org.springframework.context.annotation.Bean; +import org.springframework.integration.channel.DirectChannel; +import org.springframework.integration.dsl.IntegrationFlow; +import org.springframework.integration.dsl.IntegrationFlows; +import org.springframework.integration.dsl.SourcePollingChannelAdapterSpec; +import org.springframework.integration.dsl.core.Pollers; +import org.springframework.integration.dsl.support.Consumer; +import org.springframework.integration.file.FileReadingMessageSource; +import org.springframework.integration.file.FileWritingMessageHandler; @SpringBootApplication @EnableConfigurationProperties(ServiceProperties.class) -@ImportResource("integration-context.xml") public class SampleIntegrationApplication { + @Bean + public FileReadingMessageSource fileReader() { + FileReadingMessageSource reader = new FileReadingMessageSource(); + reader.setDirectory(new File("target/input")); + return reader; + } + + @Bean + public DirectChannel inputChannel() { + return new DirectChannel(); + } + + @Bean + public DirectChannel outputChannel() { + return new DirectChannel(); + } + + @Bean + public FileWritingMessageHandler fileWriter() { + FileWritingMessageHandler writer = new FileWritingMessageHandler( + new File("target/output")); + writer.setExpectReply(false); + return writer; + } + + @Bean + public IntegrationFlow integrationFlow(SampleEndpoint endpoint) { + return IntegrationFlows.from(fileReader(), new FixedRatePoller()) + .channel(inputChannel()).handle(endpoint).channel(outputChannel()) + .handle(fileWriter()).get(); + } + public static void main(String[] args) throws Exception { SpringApplication.run(SampleIntegrationApplication.class, args); } + private static class FixedRatePoller + implements Consumer { + + @Override + public void accept(SourcePollingChannelAdapterSpec spec) { + spec.poller(Pollers.fixedRate(500)); + } + + } + } diff --git a/spring-boot-samples/spring-boot-sample-integration/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-integration/src/main/resources/application.properties index 92dc00252b..1a34116547 100644 --- a/spring-boot-samples/spring-boot-sample-integration/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-integration/src/main/resources/application.properties @@ -1,4 +1,2 @@ -logging.file: /tmp/logs/app.log logging.level.org.springframework.integration.file: DEBUG service.greeting: Hello -debug: true \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-integration/src/main/resources/integration-context.xml b/spring-boot-samples/spring-boot-sample-integration/src/main/resources/integration-context.xml deleted file mode 100644 index 1372fe393a..0000000000 --- a/spring-boot-samples/spring-boot-sample-integration/src/main/resources/integration-context.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - diff --git a/spring-boot-starters/spring-boot-starter-integration/pom.xml b/spring-boot-starters/spring-boot-starter-integration/pom.xml index 19ea166498..62efa190ae 100644 --- a/spring-boot-starters/spring-boot-starter-integration/pom.xml +++ b/spring-boot-starters/spring-boot-starter-integration/pom.xml @@ -32,19 +32,7 @@ org.springframework.integration - spring-integration-file - - - org.springframework.integration - spring-integration-http - - - org.springframework.integration - spring-integration-ip - - - org.springframework.integration - spring-integration-stream + spring-integration-java-dsl