Minimize and centralize assumptions about build output

Closes gh-15471
This commit is contained in:
Andy Wilkinson
2018-12-14 17:50:20 +00:00
parent 7d0a7a65c8
commit 61d04db0d7
57 changed files with 778 additions and 337 deletions

View File

@@ -16,7 +16,6 @@
package sample.parent;
import java.io.File;
import java.util.function.Consumer;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -33,7 +32,6 @@ import org.springframework.integration.file.FileReadingMessageSource;
import org.springframework.integration.file.FileWritingMessageHandler;
@SpringBootApplication
@EnableConfigurationProperties(ServiceProperties.class)
public class SampleParentContextApplication {
public static void main(String[] args) throws Exception {
@@ -42,12 +40,19 @@ public class SampleParentContextApplication {
}
@EnableAutoConfiguration
@EnableConfigurationProperties(ServiceProperties.class)
protected static class Parent {
private final ServiceProperties serviceProperties;
public Parent(ServiceProperties serviceProperties) {
this.serviceProperties = serviceProperties;
}
@Bean
public FileReadingMessageSource fileReader() {
FileReadingMessageSource reader = new FileReadingMessageSource();
reader.setDirectory(new File("target/input"));
reader.setDirectory(this.serviceProperties.getInputDir());
return reader;
}
@@ -64,7 +69,7 @@ public class SampleParentContextApplication {
@Bean
public FileWritingMessageHandler fileWriter() {
FileWritingMessageHandler writer = new FileWritingMessageHandler(
new File("target/output"));
this.serviceProperties.getOutputDir());
writer.setExpectReply(false);
return writer;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2018 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,6 +16,8 @@
package sample.parent;
import java.io.File;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedResource;
@@ -26,6 +28,10 @@ public class ServiceProperties {
private String greeting = "Hello";
private File inputDir;
private File outputDir;
@ManagedAttribute
public String getGreeting() {
return this.greeting;
@@ -35,4 +41,20 @@ public class ServiceProperties {
this.greeting = greeting;
}
public File getInputDir() {
return this.inputDir;
}
public void setInputDir(File inputDir) {
this.inputDir = inputDir;
}
public File getOutputDir() {
return this.outputDir;
}
public void setOutputDir(File outputDir) {
this.outputDir = outputDir;
}
}

View File

@@ -1 +1,3 @@
service.greeting=Hello
service.input-dir=input
service.output-dir=output