Revert usage for fileNameExpression

Since we provide a custom `FileNameGenerator` via `fileNameExpression` we should ensure somehow `BeanFactory` injection to that
`FileWritingMessageHandlerSpec` is a `FactoryBean` since version DSL `1.2` and a particular `BPP` takes care about `Spec` internals and register custom `FileNameGenerator` as a bean.

 Use standard `FactoryBean` injection in the `lines()` flow to populate the target `FileWritingMessageHandler` to the flow
Generate pom for all project to apply SI Java DSL 1.2 GA
This commit is contained in:
Artem Bilan
2016-10-14 13:23:43 -04:00
committed by Gary Russell
parent a9d653b19e
commit ef31a187c4
7 changed files with 13 additions and 13 deletions

View File

@@ -71,7 +71,7 @@
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-java-dsl</artifactId>
<version>1.2.0.RC1</version>
<version>1.2.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@@ -94,7 +94,7 @@
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-java-dsl</artifactId>
<version>1.2.0.RC1</version>
<version>1.2.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@@ -31,6 +31,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlows;
import org.springframework.integration.dsl.core.Pollers;
import org.springframework.integration.dsl.file.FileWritingMessageHandlerSpec;
import org.springframework.integration.dsl.file.Files;
import org.springframework.integration.dsl.mail.Mail;
import org.springframework.integration.file.FileHeaders;
@@ -62,7 +63,7 @@ public class Application {
/**
* Poll for files, add an error channel, split into lines route the start/end markers
* to {@link #markers()} and the lines to {@link #lines()}.
* to {@link #markers()} and the lines to {@link #lines}.
* @return the flow.
*/
@Bean
@@ -84,17 +85,16 @@ public class Application {
* @return the flow.
*/
@Bean
public IntegrationFlow lines() {
return f -> f.handle(fileOut());
public IntegrationFlow lines(FileWritingMessageHandler fileOut) {
return f -> f.handle(fileOut);
}
@Bean
public FileWritingMessageHandler fileOut() {
public FileWritingMessageHandlerSpec fileOut() {
return Files.outboundAdapter("'/tmp/out'")
.appendNewLine(true)
.fileNameGenerator(m -> m.getPayload().toString().substring(1, 4) + ".txt")
.fileExistsMode(FileExistsMode.APPEND_NO_FLUSH) // files remain open for efficiency
.get();
.fileNameExpression("payload.substring(1, 4) + '.txt'")
.fileExistsMode(FileExistsMode.APPEND_NO_FLUSH); // files remain open for efficiency
}
/**

View File

@@ -77,7 +77,7 @@
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-java-dsl</artifactId>
<version>1.2.0.RC1</version>
<version>1.2.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@@ -83,7 +83,7 @@
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-java-dsl</artifactId>
<version>1.2.0.RC1</version>
<version>1.2.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@@ -71,7 +71,7 @@
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-java-dsl</artifactId>
<version>1.2.0.RC1</version>
<version>1.2.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@@ -90,7 +90,7 @@
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-java-dsl</artifactId>
<version>1.2.0.RC1</version>
<version>1.2.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>